@@ -23,25 +23,31 @@ function update_script() {
2323 header_info
2424 check_container_storage
2525 check_container_resources
26+
2627 if [[ ! -d /opt/bookstack ]]; then
2728 msg_error " No ${APP} Installation Found!"
2829 exit
2930 fi
3031 RELEASE=$( curl -fsSL https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
31- if [[ ! -f /opt/ ${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/ ${APP} _version.txt ) " ]]; then
32+ if [[ " ${RELEASE} " != " $( cat ~ /.bookstack 2> /dev/null ) " ]] || [[ ! -f ~ /.bookstack ]]; then
3233 msg_info " Stopping Apache2"
3334 systemctl stop apache2
3435 msg_ok " Services Stopped"
3536
36- msg_info " Updating ${APP} to v ${RELEASE} "
37+ msg_info " Backing up data "
3738 mv /opt/bookstack /opt/bookstack-backup
38- curl -fsSL " https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE} .zip" -o " /opt/BookStack-${RELEASE} .zip"
39- $STD unzip " /opt/BookStack-${RELEASE} .zip" -d /opt
40- mv " /opt/BookStack-${RELEASE} " /opt/bookstack
39+ msg_ok " Backup finished"
40+
41+ fetch_and_deploy_gh_release " bookstack" " BookStackApp/BookStack"
42+
43+ msg_info " Restoring backup"
4144 cp /opt/bookstack-backup/.env /opt/bookstack/.env
4245 [[ -d /opt/bookstack-backup/public/uploads ]] && cp -a /opt/bookstack-backup/public/uploads/. /opt/bookstack/public/uploads/
4346 [[ -d /opt/bookstack-backup/storage/uploads ]] && cp -a /opt/bookstack-backup/storage/uploads/. /opt/bookstack/storage/uploads/
4447 [[ -d /opt/bookstack-backup/themes ]] && cp -a /opt/bookstack-backup/themes/. /opt/bookstack/themes/
48+ msg_ok " Backup restored"
49+
50+ msg_info " Configuring BookStack"
4551 cd /opt/bookstack
4652 export COMPOSER_ALLOW_SUPERUSER=1
4753 $STD composer install --no-dev
@@ -51,15 +57,14 @@ function update_script() {
5157 chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads
5258 chmod -R 640 /opt/bookstack/.env
5359 echo " ${RELEASE} " > /opt/${APP} _version.txt
54- msg_ok " Updated ${APP} to v ${RELEASE} "
60+ msg_ok " Configured BookStack "
5561
5662 msg_info " Starting Apache2"
5763 systemctl start apache2
5864 msg_ok " Started Apache2"
5965
6066 msg_info " Cleaning Up"
6167 rm -rf /opt/bookstack-backup
62- rm -rf " /opt/BookStack-${RELEASE} .zip"
6368 msg_ok " Cleaned"
6469 msg_ok " Updated Successfully"
6570 else
0 commit comments