Appease shellcheck

This commit is contained in:
Luke Murphy 2020-09-08 08:58:49 +02:00
parent 0f6a6018bd
commit c29ce5cdda
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

20
abra
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
PROGRAM_NAME=$(basename $0) PROGRAM_NAME=""$(basename "$0")
if [ -z $STACK_NAME ] || [ -z $STACK_NAME ]; then if [ -z "$STACK_NAME" ] || [ -z "$STACK_NAME" ]; then
echo "ERROR: STACK_NAME must be set (e.g. export STACK_NAME=my_cool_app)" echo "ERROR: STACK_NAME must be set (e.g. export STACK_NAME=my_cool_app)"
exit exit
fi fi
@ -21,14 +21,14 @@ sub_secret_generate(){
SECRET=$1 SECRET=$1
VERSION=$2 VERSION=$2
if [ -z $SECRET ] || [ -z $VERSION ]; then if [ -z "$SECRET" ] || [ -z "$VERSION" ]; then
echo "Usage: $PROGRAM_NAME secret_generate SECRET VERSION" echo "Usage: $PROGRAM_NAME secret_generate SECRET VERSION"
exit exit
fi fi
pwqgen | tee \ pwqgen | tee \
>(docker secret create "${STACK_NAME}_${SECRET}_${VERSION}" -) \ >(docker secret create "${STACK_NAME}_${SECRET}_${VERSION}" -) \
>(pass insert hosts/autonomic-swarm/${STACK_NAME}/${SECRET} -m) >(pass insert "hosts/autonomic-swarm/${STACK_NAME}/${SECRET}" -m)
} }
sub_service_run(){ sub_service_run(){
@ -36,14 +36,14 @@ sub_service_run(){
SH=${2:-/bin/sh} SH=${2:-/bin/sh}
CONTAINER=$(docker container ls --format "table {{.ID}},{{.Names}}" \ CONTAINER=$(docker container ls --format "table {{.ID}},{{.Names}}" \
| grep ${STACK_NAME}_${SERVICE} | cut -d',' -f1) | grep "${STACK_NAME}_${SERVICE}" | cut -d',' -f1)
if [ -z $CONTAINER ]; then if [ -z "$CONTAINER" ]; then
echo "Container not found! 🚨" echo "Container not found! 🚨"
exit exit
fi fi
docker exec -it $CONTAINER $SH docker exec -it "$CONTAINER" "$SH"
} }
sub_deploy (){ sub_deploy (){
@ -54,7 +54,7 @@ sub_deploy (){
echo "Domain: $(tput setaf 2)${DOMAIN}$(tput sgr0)" echo "Domain: $(tput setaf 2)${DOMAIN}$(tput sgr0)"
echo "Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)" echo "Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)"
read -p "Continue? (y/[n])? " choice read -rp "Continue? (y/[n])? " choice
case "$choice" in case "$choice" in
y|Y ) ;; y|Y ) ;;
@ -62,7 +62,7 @@ sub_deploy (){
* ) return;; * ) return;;
esac esac
docker stack deploy -c $COMPOSE $STACK_NAME docker stack deploy -c "$COMPOSE" "$STACK_NAME"
} }
subcommand=$1 subcommand=$1
@ -72,7 +72,7 @@ case $subcommand in
;; ;;
*) *)
shift shift
sub_${subcommand} $@ "sub_${subcommand}" "$@"
if [ $? = 127 ]; then if [ $? = 127 ]; then
echo "Error: '$subcommand' is not a known subcommand." >&2 echo "Error: '$subcommand' is not a known subcommand." >&2
echo " Run '$PROGRAM_NAME --help' for a list of known subcommands." >&2 echo " Run '$PROGRAM_NAME --help' for a list of known subcommands." >&2