Iterate on docker-stacks
This commit is contained in:
parent
6fbc6f4eda
commit
b6042957a9
@ -28,85 +28,60 @@ function compose_down {
|
|||||||
# takes a docker-compose.yml file path and brings it up
|
# takes a docker-compose.yml file path and brings it up
|
||||||
function compose_up {
|
function compose_up {
|
||||||
STACK_PATH=$1
|
STACK_PATH=$1
|
||||||
|
if [ "$FORCERECREATE" = true ]; then
|
||||||
|
docker-compose up --force-recreate -f $STACK_PATH -d
|
||||||
|
elif [ "$FORCERECREATE" = false ]; then
|
||||||
docker-compose up -f $STACK_PATH -d
|
docker-compose up -f $STACK_PATH -d
|
||||||
|
else
|
||||||
|
echo "Bad variable value: \$FORCERECREATE=$FORCERECREATE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# takes a docker-compose.yml file path and force recreates it
|
function loop_stacks {
|
||||||
function compose_up_recreate {
|
for $stack in $STACKS_DIRECTORY; do
|
||||||
STACK_PATH=$1
|
case $COMMAND in
|
||||||
docker-compose up -d --force-recreate -f $STACK_PATH
|
up) echo "loop_stacks up";;
|
||||||
}
|
down) echo "loop_stacks down";;
|
||||||
|
*) echo "Invalid input $COMMAND at loop_stacks"; exit 1;;
|
||||||
function get_global_args {
|
esac
|
||||||
for arg in $@; do
|
|
||||||
echo "\$arg is $arg"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
echo "\$@ is $@"
|
echo "\$ARGS is $ARGS"
|
||||||
echo "Parse global flags"
|
STACKS_DIRECTORY="/home/admin/homelab/fighter/config"
|
||||||
while [ $# -gt 0 ]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
#echo "case is $1"
|
||||||
case $1 in
|
case $1 in
|
||||||
-n | --nas-only)
|
# global flags are parsed first
|
||||||
NASONLY=true
|
-n|--nas-only) NASONLY=true; shift ;;
|
||||||
;;
|
-l|--lint) LINT=true; shift ;;
|
||||||
-l | --lint)
|
-p|--path) STACKS_DIRECTORY="$2"; shift; shift ;;
|
||||||
LINT=true
|
-v|--verbose) VERBOSE=true; shift ;;
|
||||||
;;
|
# commands are parsed with nested parsing for subcommand flags
|
||||||
*)
|
up*) COMMAND="up"; shift;
|
||||||
OPERATION="$OPERATION $1"
|
while [[ $# -gt 0 ]]; do
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo "\$NASONLY is $NASONLY"
|
|
||||||
echo "\$LINT is $LINT"
|
|
||||||
echo "\$OPERATION is $OPERATION"
|
|
||||||
echo "Determine operation"
|
|
||||||
case $OPERATION in
|
|
||||||
up*)
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case $1 in
|
case $1 in
|
||||||
-f | --force)
|
-f|--force-recreate) FORCERECREATE=true; shift;;
|
||||||
FORCE=true
|
|
||||||
echo "Force is true"
|
|
||||||
;;
|
|
||||||
up)
|
|
||||||
echo "Operation is up"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unrecognized operation \'$1\'"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
echo "FORCE is $FORCE"
|
|
||||||
;;
|
;;
|
||||||
down*)
|
down*) COMMAND="down"; shift;
|
||||||
while [ $# -gt 0 ]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
down)
|
-f|--force-recreate) FORCERECREATE=true; shift;;
|
||||||
true
|
|
||||||
echo "Operation is down"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unrecognized operation \'$1\'"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
echo "FORCE is $FORCE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Operation not recognized."
|
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
|
*) echo "Unrecognized option $1"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
for stack in "$STACKS_DIRECTORY"/* ; do
|
||||||
|
echo "$stack"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_global_args "$@"
|
ARGS="$@"
|
||||||
|
|
||||||
|
main $ARGS
|
Loading…
Reference in New Issue
Block a user