Fixed upgrade ouput format, cleaner, new checks, and also fixed start script for check if app is installed

This commit is contained in:
root 2024-09-05 17:32:31 +00:00
parent 3e01c4ba84
commit 52fa17fb60
2 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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"