diff --git a/bouncerw b/bouncerw index 75274f9a..4f2e6cdd 100755 --- a/bouncerw +++ b/bouncerw @@ -10,9 +10,7 @@ lock() { echo "Attempting to lock ${lockfile}" eval "exec ${fd}>${lockfile}" - flock -w ${lock_timeout} ${fd} - - if [[ "$?" == "0" ]]; then + if flock -w ${lock_timeout} ${fd}; then echo "Lock acquired" return 0 else @@ -23,9 +21,8 @@ lock() { unlock() { echo "Releasing lock on ${lockfile}" - flock -u ${fd} - if [[ "$?" == "0" ]]; then + if flock -u ${fd}; then echo "Lock released" return 0 else @@ -39,10 +36,14 @@ download() { echo "BOUNCER_VERSION is not set. Looking for the latest bouncer release..." # Terraform Enterprise environment doesn't have jq, replace with this once it does: # export BOUNCER_VERSION=$(curl -s "https://api.bintray.com/packages/palantir/releases/bouncer" | jq -r '.latest_version') - export BOUNCER_VERSION=$(curl -s "https://api.bintray.com/packages/palantir/releases/bouncer" | egrep -oh '"latest_version":"\S*?"' | cut -d ':' -f 2 | cut -d ',' -f 1 | sed 's/"//g') + BOUNCER_VERSION=$(curl -s "https://api.bintray.com/packages/palantir/releases/bouncer" | grep -Eoh '"latest_version":"\S*?"' | cut -d ':' -f 2 | cut -d ',' -f 1 | sed 's/"//g') + export BOUNCER_VERSION fi + # Strip a leading 'v' if someone adds one, or one winds-up there somehow + BOUNCER_VERSION="${BOUNCER_VERSION//v}" + export BOUNCER_VERSION echo "Installing bouncer version ${BOUNCER_VERSION}" - wget -q -O bouncer.tgz https://palantir.bintray.com/releases/com/palantir/bouncer/bouncer/${BOUNCER_VERSION}/bouncer-${BOUNCER_VERSION}-linux-amd64.tgz + wget -q -O bouncer.tgz "https://palantir.bintray.com/releases/com/palantir/bouncer/bouncer/${BOUNCER_VERSION}/bouncer-${BOUNCER_VERSION}-linux-amd64.tgz" tar -xzf bouncer.tgz chmod 755 ./bouncer }