From 9e759d9c1a8a0a180ebb5b6aa5fb0679033b032b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:04:33 +0100 Subject: [PATCH] Add new LXC: Bookstack --- CHANGELOG.md | 16 +++++ ct/bookstack.sh | 100 +++++++++++++++++++++++++++++ install/bookstack-install.sh | 120 +++++++++++++++++++++++++++++++++++ 3 files changed, 236 insertions(+) create mode 100644 ct/bookstack.sh create mode 100644 install/bookstack-install.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1bfa92..3bacaf5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,13 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit > [!NOTE] All LXC instances created using this repository come pre-installed with Midnight Commander, which is a command-line tool (`mc`) that offers a user-friendly file and directory management interface for the terminal environment. +## 2024-11-05 + +### Changed + +- **Bookstack LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/bookstack-install.sh) + - NEW Script + ## 2024-11-04 ### Breaking Change @@ -21,6 +28,15 @@ All LXC instances created using this repository come pre-installed with Midnight ```bash bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/misc/update-repo.sh)" +## 2024-10-31 + +### Changed + +- **NZBGet LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/nzbget-install.sh) + - NEW Script +- **Memos LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/memos-install.sh) + - NEW Script + ## 2024-10-27 ### Changed diff --git a/ct/bookstack.sh b/ct/bookstack.sh new file mode 100644 index 00000000..dc7ed4f7 --- /dev/null +++ b/ct/bookstack.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/BookStackApp/BookStack + +function header_info { +clear +cat <<"EOF" + ____ __ __ __ + / __ )____ ____ / /_______/ /_____ ______/ /__ + / __ / __ \/ __ \/ //_/ ___/ __/ __ `/ ___/ //_/ + / /_/ / /_/ / /_/ / ,< (__ ) /_/ /_/ / /__/ ,< +/_____/\____/\____/_/|_/____/\__/\__,_/\___/_/|_| + +EOF +} +header_info +echo -e "Loading..." +APP="Bookstack" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/bookstack ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || 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 + msg_ok "Services Stopped" + + msg_info "Updating ${APP} to ${RELEASE}" + cp /opt/bookstack/.env /opt/.env + 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 + COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev &>/dev/null + php artisan key:generate &>/dev/null + php artisan migrate &>/dev/null + 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" + rm -rf v${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 + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}${CL} \n" diff --git a/install/bookstack-install.sh b/install/bookstack-install.sh new file mode 100644 index 00000000..86880af3 --- /dev/null +++ b/install/bookstack-install.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 communtiy-scripts ORG +# Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y \ + unzip \ + mariadb-server \ + apache2 \ + curl \ + sudo \ + php8.2-{mbstring,gd,fpm,curl,intl,ldap,tidy,bz2,mysql,zip,xml} \ + composer \ + libapache2-mod-php \ + make \ + mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Database" +DB_NAME=bookstack +DB_USER=bookstack +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +$STD sudo mysql -u root -e "CREATE DATABASE $DB_NAME;" +$STD sudo mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" +$STD sudo mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "Bookstack-Credentials" + echo "Bookstack Database User: $DB_USER" + echo "Bookstack Database Password: $DB_PASS" + echo "Bookstack Database Name: $DB_NAME" +} >> ~/bookstack.creds +msg_ok "Set up database" + +msg_info "Setup Bookstack (Patience)" +LOCAL_IP="$(hostname -I | awk '{print $1}')" +cd /opt +RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip" +unzip -q v${RELEASE}.zip +mv BookStack-${RELEASE} /opt/bookstack +cd /opt/bookstack +cp .env.example .env +sudo sed -i "s|APP_URL=.*|APP_URL=http://$LOCAL_IP|g" /opt/bookstack/.env +sudo sed -i "s/DB_DATABASE=.*/DB_DATABASE=$DB_NAME/" /opt/bookstack/.env +sudo sed -i "s/DB_USERNAME=.*/DB_USERNAME=$DB_USER/" /opt/bookstack/.env +sudo sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$DB_PASS/" /opt/bookstack/.env +$STD composer install --no-dev --no-plugins --no-interaction +$STD php artisan key:generate --no-interaction --force +$STD php artisan migrate --no-interaction --force +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 +$STD a2enmod rewrite +$STD a2enmod php8.2 +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +msg_ok "Installed Bookstack" + +msg_info "Creating Service" +cat </etc/apache2/sites-available/bookstack.conf + + ServerAdmin webmaster@localhost + DocumentRoot /opt/bookstack/public/ + + + Options -Indexes +FollowSymLinks + AllowOverride None + Require all granted + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + + + + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + + +EOF +$STD a2ensite bookstack.conf +$STD a2dissite 000-default.conf +$STD systemctl reload apache2 +msg_ok "Created Services" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf /opt/v${RELEASE}.zip +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned"