Skip to content

Commit

Permalink
bouncerw fixes (#66)
Browse files Browse the repository at this point in the history
* Adhere to shellcheck
* Strip a 'v' from version since published artifact won't have it

Co-authored-by: Holt Wilkins <[email protected]>
  • Loading branch information
holtwilkins and holtwilkins authored Jun 25, 2020
1 parent 4ceb89e commit 9d5d6d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bouncerw
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 9d5d6d5

Please sign in to comment.