added update flag to run script

This commit is contained in:
poslop
2026-04-09 10:46:46 -05:00
parent f5a01e5355
commit 0cf6b66b63
+31
View File
@@ -34,6 +34,24 @@ services=(
"pterodactyl/docker-compose.yml"
)
# Initialize update flag
UPDATE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-u|--update)
UPDATE=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [-u|--update]"
exit 1
;;
esac
done
# Start building the docker compose command with multiple -f flags
COMPOSE_COMMAND="docker compose --env-file \"$ENV_FILE\""
@@ -42,10 +60,23 @@ for service in "${services[@]}"; do
COMPOSE_COMMAND+=" -f \"$COMPOSE_DIR/$service\""
done
# If update flag is set, pull all images first
if $UPDATE; then
COMPOSE_UPDATE_COMMAND="$COMPOSE_COMMAND pull"
echo "Pulling latest images..."
eval $COMPOSE_UPDATE_COMMAND
echo "Images pulled successfully."
echo ""
fi
# Add the up command to the final docker compose command
COMPOSE_COMMAND+=" --profile panel --profile daemon up -d --remove-orphans"
# Execute the composed command
eval $COMPOSE_COMMAND
if $UPDATE; then
echo "All containers have been updated and started."
else
echo "All services have been started."
fi