mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-07-06 22:17:37 +00:00
Refactor (#5732)
This commit is contained in:
@ -23,25 +23,31 @@ function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if [[ ! -d /opt/bookstack ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
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"
|
||||
systemctl stop apache2
|
||||
msg_ok "Services Stopped"
|
||||
|
||||
msg_info "Updating ${APP} to v${RELEASE}"
|
||||
msg_info "Backing up data"
|
||||
mv /opt/bookstack /opt/bookstack-backup
|
||||
curl -fsSL "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" -o "/opt/BookStack-${RELEASE}.zip"
|
||||
$STD unzip "/opt/BookStack-${RELEASE}.zip" -d /opt
|
||||
mv "/opt/BookStack-${RELEASE}" /opt/bookstack
|
||||
msg_ok "Backup finished"
|
||||
|
||||
fetch_and_deploy_gh_release "bookstack" "BookStackApp/BookStack"
|
||||
|
||||
msg_info "Restoring backup"
|
||||
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/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/
|
||||
msg_ok "Backup restored"
|
||||
|
||||
msg_info "Configuring BookStack"
|
||||
cd /opt/bookstack
|
||||
export COMPOSER_ALLOW_SUPERUSER=1
|
||||
$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 640 /opt/bookstack/.env
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||
msg_ok "Configured BookStack"
|
||||
|
||||
msg_info "Starting Apache2"
|
||||
systemctl start apache2
|
||||
@ -59,7 +65,6 @@ function update_script() {
|
||||
|
||||
msg_info "Cleaning Up"
|
||||
rm -rf /opt/bookstack-backup
|
||||
rm -rf "/opt/BookStack-${RELEASE}.zip"
|
||||
msg_ok "Cleaned"
|
||||
msg_ok "Updated Successfully"
|
||||
else
|
||||
|
@ -15,13 +15,12 @@ update_os
|
||||
|
||||
msg_info "Installing Dependencies (Patience)"
|
||||
$STD apt-get install -y \
|
||||
apache2 \
|
||||
php8.2-{mbstring,gd,fpm,curl,intl,ldap,tidy,bz2,mysql,zip,xml} \
|
||||
composer \
|
||||
libapache2-mod-php \
|
||||
make
|
||||
apache2
|
||||
make
|
||||
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
|
||||
|
||||
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
|
||||
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}')"
|
||||
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) }')
|
||||
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
|
||||
|
||||
msg_info "Configuring Bookstack (Patience)"
|
||||
cd /opt/bookstack
|
||||
cp .env.example .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
|
||||
$STD a2enmod rewrite
|
||||
$STD a2enmod php8.2
|
||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||
msg_ok "Installed Bookstack"
|
||||
msg_ok "Configured Bookstack"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/apache2/sites-available/bookstack.conf
|
||||
@ -111,7 +106,6 @@ motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
rm -rf /opt/v${RELEASE}.zip
|
||||
$STD apt-get autoremove
|
||||
$STD apt-get autoclean
|
||||
msg_ok "Cleaned"
|
||||
|
Reference in New Issue
Block a user