2020-06-03 16:11:58 +02:00
#!/bin/bash
# (C) 2020 Kevin Woblick / LinkAce
2021-04-19 16:57:05 +02:00
set -e
2020-06-03 16:11:58 +02:00
CR = '\033[0;31m'
CG = '\033[0;32m'
CY = '\033[0;33m'
CW = '\033[0m'
printf " \n ${ CG } ==============================\n "
printf " LinkAce Docker Update Script \n"
printf "==============================\n\n"
2021-04-19 16:57:05 +02:00
printf " ${ CW } This script assumes you are using the standard Docker setup for Linkace. Only use this script if you did NOT modify any Docker-related files.\n ${ CR } Please make a backup of your database before you continue!\n "
2020-06-03 16:11:58 +02:00
# Confirm that the user wants to update now
printf " \n ${ CR } Do you want to upgrade LinkAce now? [y/n] ${ CW } "
read -n 1 -r
if [ [ ! $REPLY = ~ ^[ Yy] $ ] ] ; then exit;
fi
# Check if Docker and docker-compose are installed
command -v docker-compose >/dev/null 2>& 1 || {
printf " \n ${ CR } Docker and docker-compose must be installed for this script to work. Aborting. ${ CW } \n " ;
exit 1;
}
printf "\n> Deleting the application container volume...\n"
docker-compose down
printf "\n> Deleting the application container volume...\n"
docker volume rm linkace_linkace_app
printf "\n> Pulling latest LinkAce image from the Docker Hub...\n"
2021-04-09 10:16:33 +02:00
if grep -q "linkace/linkace:simple" docker-compose.yml; then
docker pull linkace/linkace:simple
2021-03-06 20:34:09 +01:00
else
docker pull linkace/linkace
fi
2020-06-03 16:11:58 +02:00
printf "\n> Restarting the application...\n"
docker-compose up -d
printf " \n ${ CG } The LinkAce image was successfully updated. ${ CW } \n "
# Confirm that the user wants to update now
printf " \n ${ CY } You should upgrade the database now. Should the script take care of it? [y/n] ${ CW } "
read -n 1 -r
if [ [ ! $REPLY = ~ ^[ Yy] $ ] ] ; then
printf "\nYou can manually update the database by running"
2021-04-19 16:57:05 +02:00
printf " \n $ docker-compose run app php artisan migrate\n "
2020-06-03 16:11:58 +02:00
exit;
fi
printf "\n> Migrating database...\n"
2021-04-19 16:57:05 +02:00
docker-compose run app php artisan migrate --force
2020-06-03 16:11:58 +02:00
printf " \n ${ CG } LinkAce was upgraded successfully!\n "
2020-08-13 09:13:49 +02:00
# Ask the user for caching
printf " \n ${ CR } Should the configuration and routes be cached now? This might improve overall performance. [y/n] ${ CW } "
read -n 1 -r
if [ [ ! $REPLY = ~ ^[ Yy] $ ] ] ; then exit;
fi
2021-04-19 16:57:05 +02:00
docker-compose run app php artisan config:cache
docker-compose run app php artisan route:cache
2020-08-13 09:13:49 +02:00
printf " \n ${ CG } Thanks for using LinkAce! :)\n "