-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from MickLesk/main
Add new LXC: Bookstack
- Loading branch information
Showing
3 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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? <y/N> " 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <<EOF >/etc/apache2/sites-available/bookstack.conf | ||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /opt/bookstack/public/ | ||
<Directory /opt/bookstack/public/> | ||
Options -Indexes +FollowSymLinks | ||
AllowOverride None | ||
Require all granted | ||
<IfModule mod_rewrite.c> | ||
<IfModule mod_negotiation.c> | ||
Options -MultiViews -Indexes | ||
</IfModule> | ||
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] | ||
</IfModule> | ||
</Directory> | ||
ErrorLog /var/log/apache2/error.log | ||
CustomLog /var/log/apache2/access.log combined | ||
</VirtualHost> | ||
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" |