Last active
August 29, 2015 14:16
-
-
Save Pindar/300d3424f05410ad7c04 to your computer and use it in GitHub Desktop.
set-env.sh
This file contains 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 | |
FILE=${1} | |
ENVIRONMENT=${2} | |
SERVICE_NAME=${3} | |
ETCD=${4:-"127.0.0.1:4001"} | |
if [[ $FILE == "" || $ENVIRONMENT == "" || SERVICE_NAME == "" ]]; then | |
echo "Please specify file, environment and service name" | |
echo "Usage: ./set-env.sh pwd/fileenv staging myservice" | |
exit 1; | |
fi | |
while read -r line || [[ -n $line ]] | |
do | |
if [[ `echo $line | grep -c -e '^$'` -eq 1 ]]; then | |
continue; | |
fi | |
if [[ `echo $line | grep -c "^#"` -eq 1 ]]; then | |
continue; | |
fi | |
KEY=`echo $line | cut -d "=" -sf 1` | |
VALUE=`echo $line | cut -d "=" -sf 2-` | |
echo [set-env] set /$ENVIRONMENT/$SERVICE_NAME/$KEY "$VALUE" | |
echo "${VALUE}" | etcdctl --peers $ETCD set /$ENVIRONMENT/$SERVICE_NAME/$KEY | |
done < $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment