iterate on docker-stacks

This commit is contained in:
Joey Hafner 2023-10-10 14:29:53 -07:00
parent 10898c1b20
commit 84c947ec49

View File

@ -13,12 +13,17 @@ function check_nas {
# takes a docker-compose.yml file path and returns a boolean to represent # takes a docker-compose.yml file path and returns a boolean to represent
# whether that stack passes a docker-compose config lint # whether that stack passes a docker-compose config lint
function valid_compose { function lint {
STACK_PATH=$1 STACK_PATH=$1
docker-compose config -f $STACK_PATH > /dev/null 2>&1 docker-compose config -f $STACK_PATH > /dev/null 2>&1
return $? return $?
} }
function compose_config {
STACK_PATH=$1
docker-compose config -f $STACK_PATH
}
# takes a docker-compose.yml file path and shuts it down # takes a docker-compose.yml file path and shuts it down
function compose_down { function compose_down {
STACK_PATH=$1 STACK_PATH=$1
@ -37,16 +42,6 @@ function compose_up {
fi fi
} }
function loop_stacks {
for $stack in $STACKS_DIRECTORY; do
case $COMMAND in
up) echo "loop_stacks up";;
down) echo "loop_stacks down";;
*) echo "Invalid input $COMMAND at loop_stacks"; exit 1;;
esac
done
}
function main { function main {
#echo "\$ARGS is $ARGS" #echo "\$ARGS is $ARGS"
STACKS_DIRECTORY="/home/admin/homelab/fighter/config" STACKS_DIRECTORY="/home/admin/homelab/fighter/config"
@ -63,7 +58,7 @@ function main {
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-f|--force-recreate) FORCE_RECREATE=true; shift;; -f|--force-recreate) FORCE_RECREATE=true; shift;;
*) echo "Unrecognized option '$1'"; exit 1;; *) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
esac esac
done done
;; ;;
@ -71,7 +66,15 @@ function main {
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-o|--remove-orphans) REMOVE_ORPHANS=true; shift;; -o|--remove-orphans) REMOVE_ORPHANS=true; shift;;
*) echo "Unrecognized option '$1'"; exit 1;; *) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
esac
done
;;
config*) COMMAND="config"; shift;
while [[ $# -gt 0 ]]; do
case $1 in
-n|--no-interpolate) NO_INTERPOLATE=true; shift;;
*) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
esac esac
done done
;; ;;
@ -80,10 +83,10 @@ function main {
done done
for stack in "$STACKS_DIRECTORY"/* ; do for stack in "$STACKS_DIRECTORY"/* ; do
cd $stack/
case $COMMAND in case $COMMAND in
up) echo "Run compose-up from ${PWD}" ;; up) echo "$COMMAND on $stack" ;;
down) echo "Run compose-down from ${PWD}" ;; down) echo "$COMMAND on $stack" ;;
config) compose_config $stack ;;
*) echo "Unrecognized command '$COMMAND'" ;; *) echo "Unrecognized command '$COMMAND'" ;;
esac esac
done done