From 9eb03fdc18ebaa7c67f3decd3e81add329f0d4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 7 Dec 2023 23:16:28 +0100 Subject: [PATCH] Update script: do not always pull --- update.sh | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 15deb40..e2bb2c2 100755 --- a/update.sh +++ b/update.sh @@ -5,11 +5,48 @@ set -e HERE=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) cd "$HERE" +# Default variable values +should_pull=false + +# Function to display script usage +usage() { + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -h, --help Display this help message" + echo " -p, --pull Pulls all docker images" +} + +# Function to handle options and arguments +handle_options() { + while [ $# -gt 0 ]; do + case $1 in + -h | --help) + usage + exit 0 + ;; + -p | --pull) + should_pull=true + ;; + *) + echo "Invalid option: $1" >&2 + usage + exit 1 + ;; + esac + shift + done +} + +# Main script execution +handle_options "$@" + echo "Updating repo from Github" git pull -echo "Updating docker images" -docker-compose pull +if [ "$should_pull" = true ]; then + echo "Updating docker images" + docker-compose pull +fi echo "Launching updated services" docker-compose up -d