Created
February 23, 2018 18:14
-
-
Save brianshumate/ba3d49e4784657bc60cd712ca20ae05d to your computer and use it in GitHub Desktop.
Token Colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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