Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ct/bookstack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,15 +57,14 @@ 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
msg_ok "Started Apache2"

msg_info "Cleaning Up"
rm -rf /opt/bookstack-backup
rm -rf "/opt/BookStack-${RELEASE}.zip"
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
Expand Down
22 changes: 8 additions & 14 deletions install/bookstack-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"