From 79ea66746e348dd0bf6fbb18316f40c0a2d1a76c Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 10 Dec 2024 14:34:25 +0100 Subject: [PATCH 1/6] Rework Update function --- ct/bookstack.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index 09e623a7..ac8e9569 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -63,27 +63,37 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v msg_info "Stopping Apache2" systemctl stop apache2 msg_ok "Services Stopped" - msg_info "Updating ${APP} to ${RELEASE}" - cp /opt/bookstack/.env /opt/.env + cp -r /opt/bookstack/ /opt/bookstack-backup + tar -czf /opt/bookstack_backup_${RELEASE}.tar.gz /opt/bookstack/.env /opt/bookstack/public/uploads /opt/bookstack/storage/uploads /opt/bookstack/themes &>/dev/null + mysqldump -u root bookstack > /opt/bookstack_backup_${RELEASE}.sql + rm -rf /opt/bookstack/* wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" unzip -q v${RELEASE}.zip - mv BookStack-${RELEASE} /opt/bookstack - mv /opt/.env /opt/bookstack/.env + mv BookStack-${RELEASE}/* /opt/bookstack + cp /opt/bookstack-backup/.env /opt/bookstack/.env + cp -r /opt/bookstack-backup/public/uploads/ /opt/bookstack/public/uploads + cp -r /opt/bookstack-backup/storage/uploads/ /opt/bookstack/storage/uploads + cp -r /opt/bookstack-backup/themes/ /opt/bookstack/themes cd /opt/bookstack COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev &>/dev/null php artisan key:generate --force &>/dev/null php artisan migrate --force &>/dev/null + chown www-data:www-data -R /opt/bookstack /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads /opt/bookstack/storage + chmod -R 755 /opt/bookstack /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads /opt/bookstack/storage + chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads + chmod -R 640 /opt/bookstack/.env echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" - - msg_info "Starting Apache2" + msg_info "Starting Apache2 " systemctl start apache2 msg_ok "Started Apache2" - msg_info "Cleaning Up" - rm -rf v${RELEASE}.zip - msg_ok "Cleaned" + cd /root/ + rm -rf /opt/bookstack-backup + rm -rf ${RELEASE}.zip + rm -rf BookStack-${RELEASE} + msg_ok "Cleaned" msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" From 2ba4f0aa3ea4e1b14d020a320cbb95f45da4b94d Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 10 Dec 2024 14:36:51 +0100 Subject: [PATCH 2/6] Rework Update function --- ct/bookstack.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index ac8e9569..f3a5f570 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -60,9 +60,11 @@ check_container_resources if [[ ! -d /opt/bookstack ]]; then msg_error "No ${APP} Installation Found!"; exit; fi RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Apache2" - systemctl stop apache2 + systemctl stop apache2t msg_ok "Services Stopped" + msg_info "Updating ${APP} to ${RELEASE}" cp -r /opt/bookstack/ /opt/bookstack-backup tar -czf /opt/bookstack_backup_${RELEASE}.tar.gz /opt/bookstack/.env /opt/bookstack/public/uploads /opt/bookstack/storage/uploads /opt/bookstack/themes &>/dev/null @@ -85,15 +87,18 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v chmod -R 640 /opt/bookstack/.env echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" + msg_info "Starting Apache2 " systemctl start apache2 msg_ok "Started Apache2" + msg_info "Cleaning Up" cd /root/ rm -rf /opt/bookstack-backup rm -rf ${RELEASE}.zip rm -rf BookStack-${RELEASE} msg_ok "Cleaned" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" From 5de71e182db0f64f8015e1f09d25b23f7d9d845f Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 10 Dec 2024 15:17:14 +0100 Subject: [PATCH 3/6] Rework Update function --- ct/bookstack.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index f3a5f570..848002eb 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -62,13 +62,13 @@ RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/l if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then msg_info "Stopping Apache2" - systemctl stop apache2t + systemctl stop apache2 msg_ok "Services Stopped" msg_info "Updating ${APP} to ${RELEASE}" - cp -r /opt/bookstack/ /opt/bookstack-backup - tar -czf /opt/bookstack_backup_${RELEASE}.tar.gz /opt/bookstack/.env /opt/bookstack/public/uploads /opt/bookstack/storage/uploads /opt/bookstack/themes &>/dev/null - mysqldump -u root bookstack > /opt/bookstack_backup_${RELEASE}.sql + mv /opt/bookstack/ /opt/bookstack-backup + tar -czf /opt/bookstack-backup_${RELEASE}.tar.gz /opt/bookstack/.env /opt/bookstack/public/uploads /opt/bookstack/storage/uploads /opt/bookstack/themes &>/dev/null + mysqldump -u root bookstack > /opt/bookstack-backup_${RELEASE}.sql rm -rf /opt/bookstack/* wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" unzip -q v${RELEASE}.zip @@ -88,7 +88,7 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" - msg_info "Starting Apache2 " + msg_info "Starting Apache2" systemctl start apache2 msg_ok "Started Apache2" @@ -98,7 +98,7 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v rm -rf ${RELEASE}.zip rm -rf BookStack-${RELEASE} msg_ok "Cleaned" - + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" From 2cb82edcb514b11da6f864b8b87bedad1abdda84 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 10 Dec 2024 15:26:47 +0100 Subject: [PATCH 4/6] Testing --- ct/bookstack.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index 848002eb..565733a6 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -93,10 +93,9 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v msg_ok "Started Apache2" msg_info "Cleaning Up" - cd /root/ rm -rf /opt/bookstack-backup - rm -rf ${RELEASE}.zip - rm -rf BookStack-${RELEASE} + rm -rf ~/${RELEASE}.zip + rm -rf ~/BookStack-${RELEASE} msg_ok "Cleaned" msg_ok "Updated Successfully" From 403c899dc11c15df09537a55aa8133c6db0e98ed Mon Sep 17 00:00:00 2001 From: "michel.roegl-brunner@htl-braunau.at" Date: Wed, 11 Dec 2024 15:17:11 +0100 Subject: [PATCH 5/6] Changes --- ct/bookstack.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index 565733a6..ed8c0f88 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -60,19 +60,14 @@ check_container_resources if [[ ! -d /opt/bookstack ]]; then msg_error "No ${APP} Installation Found!"; exit; fi RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then - msg_info "Stopping Apache2" - systemctl stop apache2 + systemctl stop apache2 msg_ok "Services Stopped" - msg_info "Updating ${APP} to ${RELEASE}" - mv /opt/bookstack/ /opt/bookstack-backup - tar -czf /opt/bookstack-backup_${RELEASE}.tar.gz /opt/bookstack/.env /opt/bookstack/public/uploads /opt/bookstack/storage/uploads /opt/bookstack/themes &>/dev/null - mysqldump -u root bookstack > /opt/bookstack-backup_${RELEASE}.sql - rm -rf /opt/bookstack/* + mv /opt/bookstack /opt/bookstack-backup wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" unzip -q v${RELEASE}.zip - mv BookStack-${RELEASE}/* /opt/bookstack + mv BookStack-${RELEASE}/ /opt/bookstack cp /opt/bookstack-backup/.env /opt/bookstack/.env cp -r /opt/bookstack-backup/public/uploads/ /opt/bookstack/public/uploads cp -r /opt/bookstack-backup/storage/uploads/ /opt/bookstack/storage/uploads @@ -87,23 +82,21 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v chmod -R 640 /opt/bookstack/.env echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" - msg_info "Starting Apache2" systemctl start apache2 msg_ok "Started Apache2" - msg_info "Cleaning Up" + cd /root/ rm -rf /opt/bookstack-backup - rm -rf ~/${RELEASE}.zip - rm -rf ~/BookStack-${RELEASE} + rm -rf ${RELEASE}.zip msg_ok "Cleaned" - msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" fi exit } + start build_container description From 4c4177e9a60c1d6bef10906306243da579d37866 Mon Sep 17 00:00:00 2001 From: "michel.roegl-brunner@htl-braunau.at" Date: Thu, 12 Dec 2024 10:06:06 +0100 Subject: [PATCH 6/6] Further changes --- ct/bookstack.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ct/bookstack.sh b/ct/bookstack.sh index ed8c0f88..9da3e744 100644 --- a/ct/bookstack.sh +++ b/ct/bookstack.sh @@ -63,11 +63,11 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v msg_info "Stopping Apache2" systemctl stop apache2 msg_ok "Services Stopped" - msg_info "Updating ${APP} to ${RELEASE}" + msg_info "Updating ${APP} to v${RELEASE}" mv /opt/bookstack /opt/bookstack-backup - wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" - unzip -q v${RELEASE}.zip - mv BookStack-${RELEASE}/ /opt/bookstack + wget -q --directory-prefix=/root/ "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" + unzip -q ~/v${RELEASE}.zip + mv ~/BookStack-${RELEASE} /opt/bookstack cp /opt/bookstack-backup/.env /opt/bookstack/.env cp -r /opt/bookstack-backup/public/uploads/ /opt/bookstack/public/uploads cp -r /opt/bookstack-backup/storage/uploads/ /opt/bookstack/storage/uploads @@ -82,17 +82,16 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v chmod -R 640 /opt/bookstack/.env echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" - msg_info "Starting Apache2" + msg_info "Starting Apache2 " systemctl start apache2 msg_ok "Started Apache2" msg_info "Cleaning Up" - cd /root/ rm -rf /opt/bookstack-backup - rm -rf ${RELEASE}.zip + rm -rf ~/v${RELEASE}.zip msg_ok "Cleaned" msg_ok "Updated Successfully" else - msg_ok "No update required. ${APP} is already at ${RELEASE}" + msg_ok "No update required. ${APP} is already at v${RELEASE}" fi exit }