This commit is contained in:
Slaviša Arežina 2025-07-05 22:30:08 +02:00 committed by GitHub
parent ae24b56c61
commit e140631760
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 21 deletions

View File

@ -23,25 +23,31 @@ function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /opt/bookstack ]]; then if [[ ! -d /opt/bookstack ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') RELEASE=$(curl -fsSL 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 if [[ "${RELEASE}" != "$(cat ~/.bookstack 2>/dev/null)" ]] || [[ ! -f ~/.bookstack ]]; then
msg_info "Stopping Apache2" msg_info "Stopping Apache2"
systemctl stop apache2 systemctl stop apache2
msg_ok "Services Stopped" msg_ok "Services Stopped"
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Backing up data"
mv /opt/bookstack /opt/bookstack-backup mv /opt/bookstack /opt/bookstack-backup
curl -fsSL "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" -o "/opt/BookStack-${RELEASE}.zip" msg_ok "Backup finished"
$STD unzip "/opt/BookStack-${RELEASE}.zip" -d /opt
mv "/opt/BookStack-${RELEASE}" /opt/bookstack fetch_and_deploy_gh_release "bookstack" "BookStackApp/BookStack"
msg_info "Restoring backup"
cp /opt/bookstack-backup/.env /opt/bookstack/.env cp /opt/bookstack-backup/.env /opt/bookstack/.env
[[ -d /opt/bookstack-backup/public/uploads ]] && cp -a /opt/bookstack-backup/public/uploads/. /opt/bookstack/public/uploads/ [[ -d /opt/bookstack-backup/public/uploads ]] && cp -a /opt/bookstack-backup/public/uploads/. /opt/bookstack/public/uploads/
[[ -d /opt/bookstack-backup/storage/uploads ]] && cp -a /opt/bookstack-backup/storage/uploads/. /opt/bookstack/storage/uploads/ [[ -d /opt/bookstack-backup/storage/uploads ]] && cp -a /opt/bookstack-backup/storage/uploads/. /opt/bookstack/storage/uploads/
[[ -d /opt/bookstack-backup/themes ]] && cp -a /opt/bookstack-backup/themes/. /opt/bookstack/themes/ [[ -d /opt/bookstack-backup/themes ]] && cp -a /opt/bookstack-backup/themes/. /opt/bookstack/themes/
msg_ok "Backup restored"
msg_info "Configuring BookStack"
cd /opt/bookstack cd /opt/bookstack
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-dev $STD composer install --no-dev
@ -51,7 +57,7 @@ function update_script() {
chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads
chmod -R 640 /opt/bookstack/.env chmod -R 640 /opt/bookstack/.env
echo "${RELEASE}" >/opt/${APP}_version.txt echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to v${RELEASE}" msg_ok "Configured BookStack"
msg_info "Starting Apache2" msg_info "Starting Apache2"
systemctl start apache2 systemctl start apache2
@ -59,7 +65,6 @@ function update_script() {
msg_info "Cleaning Up" msg_info "Cleaning Up"
rm -rf /opt/bookstack-backup rm -rf /opt/bookstack-backup
rm -rf "/opt/BookStack-${RELEASE}.zip"
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else else

View File

@ -15,13 +15,12 @@ update_os
msg_info "Installing Dependencies (Patience)" msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y \ $STD apt-get install -y \
apache2 \ apache2
php8.2-{mbstring,gd,fpm,curl,intl,ldap,tidy,bz2,mysql,zip,xml} \
composer \
libapache2-mod-php \
make make
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PHP_MODULE="fpm, ldap, tidy, bz2, mysql" PHP_FPM="YES" PHP_APACHE="YES" PHP_VERSION="8.2" setup_php
setup_composer
setup_mariadb setup_mariadb
msg_info "Setting up Database" msg_info "Setting up Database"
@ -39,13 +38,10 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS
} >>~/bookstack.creds } >>~/bookstack.creds
msg_ok "Set up database" msg_ok "Set up database"
msg_info "Setup Bookstack (Patience)" fetch_and_deploy_gh_release "bookstack" "BookStackApp/BookStack"
LOCAL_IP="$(hostname -I | awk '{print $1}')" LOCAL_IP="$(hostname -I | awk '{print $1}')"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') msg_info "Configuring Bookstack (Patience)"
curl -fsSL "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" -o "v${RELEASE}.zip"
$STD unzip v${RELEASE}.zip
mv BookStack-${RELEASE} /opt/bookstack
cd /opt/bookstack cd /opt/bookstack
cp .env.example .env cp .env.example .env
sudo sed -i "s|APP_URL=.*|APP_URL=http://$LOCAL_IP|g" /opt/bookstack/.env sudo sed -i "s|APP_URL=.*|APP_URL=http://$LOCAL_IP|g" /opt/bookstack/.env
@ -61,8 +57,7 @@ chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstac
chmod -R 640 /opt/bookstack/.env chmod -R 640 /opt/bookstack/.env
$STD a2enmod rewrite $STD a2enmod rewrite
$STD a2enmod php8.2 $STD a2enmod php8.2
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Configured Bookstack"
msg_ok "Installed Bookstack"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/bookstack.conf cat <<EOF >/etc/apache2/sites-available/bookstack.conf
@ -111,7 +106,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf /opt/v${RELEASE}.zip
$STD apt-get autoremove $STD apt-get autoremove
$STD apt-get autoclean $STD apt-get autoclean
msg_ok "Cleaned" msg_ok "Cleaned"