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
|
||||||
docker-compose up -f $STACK_PATH -d
|
if [ "$FORCERECREATE" = true ]; then
|
||||||
|
docker-compose up --force-recreate -f $STACK_PATH -d
|
||||||
|
elif [ "$FORCERECREATE" = false ]; then
|
||||||
|
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 ;;
|
||||||
|
-p|--path) STACKS_DIRECTORY="$2"; shift; shift ;;
|
||||||
|
-v|--verbose) VERBOSE=true; shift ;;
|
||||||
|
# commands are parsed with nested parsing for subcommand flags
|
||||||
|
up*) COMMAND="up"; shift;
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-f|--force-recreate) FORCERECREATE=true; shift;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
-l | --lint)
|
down*) COMMAND="down"; shift;
|
||||||
LINT=true
|
while [[ $# -gt 0 ]]; do
|
||||||
;;
|
case $1 in
|
||||||
*)
|
-f|--force-recreate) FORCERECREATE=true; shift;;
|
||||||
OPERATION="$OPERATION $1"
|
esac
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
|
*) echo "Unrecognized option $1"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
echo "\$NASONLY is $NASONLY"
|
|
||||||
echo "\$LINT is $LINT"
|
for stack in "$STACKS_DIRECTORY"/* ; do
|
||||||
echo "\$OPERATION is $OPERATION"
|
echo "$stack"
|
||||||
echo "Determine operation"
|
done
|
||||||
case $OPERATION in
|
|
||||||
up*)
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case $1 in
|
|
||||||
-f | --force)
|
|
||||||
FORCE=true
|
|
||||||
echo "Force is true"
|
|
||||||
;;
|
|
||||||
up)
|
|
||||||
echo "Operation is up"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unrecognized operation \'$1\'"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo "FORCE is $FORCE"
|
|
||||||
;;
|
|
||||||
down*)
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case $1 in
|
|
||||||
down)
|
|
||||||
true
|
|
||||||
echo "Operation is down"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unrecognized operation \'$1\'"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo "FORCE is $FORCE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Operation not recognized."
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_global_args "$@"
|
ARGS="$@"
|
||||||
|
|
||||||
|
main $ARGS
|
Loading…
Reference in New Issue
Block a user