Skip to content

Instantly share code, notes, and snippets.

@brianshumate
Created February 23, 2018 18:14
Show Gist options
  • Save brianshumate/ba3d49e4784657bc60cd712ca20ae05d to your computer and use it in GitHub Desktop.
Save brianshumate/ba3d49e4784657bc60cd712ca20ae05d to your computer and use it in GitHub Desktop.
Token Colors
#!/bin/bash
if ! [ -z "$VAULT_TOKEN" ]; then
SRCTOKEN="$VAULT_TOKEN"
else
if [ -f "$HOME/.vault-token" ]; then
SRCTOKEN=$(cat "$HOME/.vault-token")
fi
fi
if [ "$SRCTOKEN" == "" ]; then
echo "Could not find a Vault token in VAULT_TOKEN environment variable or $HOME/.vault-token — valiantly giving up!"
exit 1
fi
Z="0000"
C=${SRCTOKEN//-/}
IP="$C$Z"
IZ=$(echo "$IP" | fold -w6 | paste -sd',' -)
F=$(echo "$IP" | sed 's/.\{6\}/&\.png /g')
for COLOR in ${IZ//,/ }; do
if ! convert -size 64x64 xc:#"$COLOR" "$COLOR.png"; then
echo "Conversion failed!" 2>&1
exit 1
fi
done
if ! montage $F -tile 6x1 -geometry 64x64+0+0 vault_token.png; then
echo "Montage failed!" 2>&1
exit 1
fi
for COLOR in ${IZ//,/ }; do
rm -f "$COLOR.png"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment