From 52fa17fb60ebc79a540e5f6e59155becd635486b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Sep 2024 17:32:31 +0000 Subject: [PATCH] Fixed upgrade ouput format, cleaner, new checks, and also fixed start script for check if app is installed --- bin/start | 1 + lib/functions.sh | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/bin/start b/bin/start index 5787ba2..8227165 100755 --- a/bin/start +++ b/bin/start @@ -143,6 +143,7 @@ elif [ "$SERVICE" = "all" ]; then wait exit 0 elif printf '%s\0' "${SERVICES[@]}" | grep -Fxqz -- "$SERVICE"; then + [ ! -d "/federated/apps/$SERVICE" ] && echo "* $SERVICE is not installed." && exit 2 # If app is already running then skip [ "$(docker container inspect -f '{{.State.Status}}' $SERVICE 2>/dev/null)" = "running" ] && echo "* $SERVICE is already running." && exit 2 startservice diff --git a/lib/functions.sh b/lib/functions.sh index e6eaade..7c95059 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -101,14 +101,15 @@ upgrade_federated() { cd /federated && git pull https://installcore:$API_TOKEN@code.federated.company/federatedcomputer/Core [ $? -ne 0 ] && fail "Git pull not working on update of federated." - echo -ne "\n* Checking installed app versions with the latest.." + echo -ne "\n* Checking installed app versions with latest-versions." [ ! -f "/federated/lib/latest-versions" ] && fail "File /federated/lib/latest-version doesn't exist." + APP_DOTS='......................' for i in `cat /federated/lib/latest-versions`; do SERVICE=(${i//=/ }); APP="${SERVICE[0]}" VERSION="${SERVICE[1]}" - echo -ne "\n** Checking $APP.." + printf "\n%s %s" "$APP" "${APP_DOTS:${#APP}} " if [ -f "/federated/apps/$APP/.env" ]; then [[ $(grep IMAGE_VERSION_HOLD /federated/apps/$APP/.env) ]] && echo -ne "\n version hold found, skipping." && continue @@ -117,28 +118,30 @@ upgrade_federated() { APP_VERSION="${APP_VERSION_RAW//\"}" if [ "$APP_VERSION" = "$VERSION" ]; then - echo -ne "\n $APP is already at the latest version." + printf "%s" "is already at the latest version." else NC_COMMAND=`grep start_service /federated/lib/$APP.sh | awk -F\" '{ print $4 }'` - echo -ne "\n Upgrading $APP to $VERSION.." - echo -ne "\n Shutting Down $APP.." - cd /federated/apps/$APP && docker-compose -f docker-compose.yml -p $APP down + echo -ne "upgrading to $VERSION..\n" + if [[ ! "$APP_NOTRUNNING" ]]; then + echo -ne "\n Shutting Down $APP.." + cd /federated/apps/$APP && docker-compose -f docker-compose.yml -p $APP down + fi if [ "$APP" = "jitsi" ]; then sed -i "s/#JITSI_IMAGE_VERSION=.*/JITSI_IMAGE_VERSION=$VERSION/g" /federated/apps/$APP/.env sed -i "s/JITSI_IMAGE_VERSION=.*/JITSI_IMAGE_VERSION=$VERSION/g" /federated/apps/$APP/.env - else + else sed -i "s#VERSION=.*#VERSION=$VERSION#g" /federated/apps/$APP/.env fi if [[ "$APP_NOTRUNNING" ]]; then - echo -ne "\n $APP was already shut down so we won't be starting it.." + echo -ne "$APP was already shut down so we won't be starting it.\n" else - echo -ne "\n Starting Up $APP.." /federated/bin/start $APP - echo -ne "\n Done Updating $APP to $VERSION." + echo -ne "Done upgrading $APP to $VERSION.\n" fi fi + APP_NOTRUNNING="" else - echo -ne "not found." + printf "%s" "not installed." fi done echo -ne "\n"