Skip to content

Commit 4604e72

Browse files
authored
Merge pull request #76 from MickLesk/main
Add new LXC: Bookstack
2 parents f53f907 + 9e759d9 commit 4604e72

File tree

3 files changed

+236
-0
lines changed

3 files changed

+236
-0
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
1313
> [!NOTE]
1414
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.
1515

16+
## 2024-11-05
17+
18+
### Changed
19+
20+
- **Bookstack LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/bookstack-install.sh)
21+
- NEW Script
22+
1623
## 2024-11-04
1724

1825
### Breaking Change
@@ -21,6 +28,15 @@ All LXC instances created using this repository come pre-installed with Midnight
2128
```bash
2229
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/misc/update-repo.sh)"
2330

31+
## 2024-10-31
32+
33+
### Changed
34+
35+
- **NZBGet LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/nzbget-install.sh)
36+
- NEW Script
37+
- **Memos LXC** [(View Source)](https://github.com/community-scripts/ProxmoxVE/blob/main/install/memos-install.sh)
38+
- NEW Script
39+
2440
## 2024-10-27
2541

2642
### Changed

ct/bookstack.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2024 tteck
4+
# Author: MickLesk (Canbiz)
5+
# License: MIT
6+
# https://github.com/tteck/Proxmox/raw/main/LICENSE
7+
# Source: https://github.com/BookStackApp/BookStack
8+
9+
function header_info {
10+
clear
11+
cat <<"EOF"
12+
____ __ __ __
13+
/ __ )____ ____ / /_______/ /_____ ______/ /__
14+
/ __ / __ \/ __ \/ //_/ ___/ __/ __ `/ ___/ //_/
15+
/ /_/ / /_/ / /_/ / ,< (__ ) /_/ /_/ / /__/ ,<
16+
/_____/\____/\____/_/|_/____/\__/\__,_/\___/_/|_|
17+
18+
EOF
19+
}
20+
header_info
21+
echo -e "Loading..."
22+
APP="Bookstack"
23+
var_disk="4"
24+
var_cpu="1"
25+
var_ram="1024"
26+
var_os="debian"
27+
var_version="12"
28+
variables
29+
color
30+
catch_errors
31+
32+
function default_settings() {
33+
CT_TYPE="1"
34+
PW=""
35+
CT_ID=$NEXTID
36+
HN=$NSAPP
37+
DISK_SIZE="$var_disk"
38+
CORE_COUNT="$var_cpu"
39+
RAM_SIZE="$var_ram"
40+
BRG="vmbr0"
41+
NET="dhcp"
42+
GATE=""
43+
APT_CACHER=""
44+
APT_CACHER_IP=""
45+
DISABLEIP6="no"
46+
MTU=""
47+
SD=""
48+
NS=""
49+
MAC=""
50+
VLAN=""
51+
SSH="no"
52+
VERB="no"
53+
echo_default
54+
}
55+
56+
function update_script() {
57+
header_info
58+
if [[ ! -d /opt/bookstack ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
59+
if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then
60+
read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt
61+
[[ ${prompt,,} =~ ^(y|yes)$ ]] || exit
62+
fi
63+
RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
64+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
65+
msg_info "Stopping Apache2"
66+
systemctl stop apache2
67+
msg_ok "Services Stopped"
68+
69+
msg_info "Updating ${APP} to ${RELEASE}"
70+
cp /opt/bookstack/.env /opt/.env
71+
wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip"
72+
unzip -q v${RELEASE}.zip
73+
mv BookStack-${RELEASE} /opt/bookstack
74+
mv /opt/.env /opt/bookstack/.env
75+
COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev &>/dev/null
76+
php artisan key:generate &>/dev/null
77+
php artisan migrate &>/dev/null
78+
echo "${RELEASE}" >/opt/${APP}_version.txt
79+
msg_ok "Updated ${APP}"
80+
81+
msg_info "Starting Apache2"
82+
systemctl start apache2
83+
msg_ok "Started Apache2"
84+
85+
msg_info "Cleaning Up"
86+
rm -rf v${RELEASE}.zip
87+
msg_ok "Cleaned"
88+
msg_ok "Updated Successfully"
89+
else
90+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
91+
fi
92+
exit
93+
}
94+
start
95+
build_container
96+
description
97+
98+
msg_ok "Completed Successfully!\n"
99+
echo -e "${APP} Setup should be reachable by going to the following URL.
100+
${BL}http://${IP}${CL} \n"

install/bookstack-install.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2024 communtiy-scripts ORG
4+
# Author: MickLesk (Canbiz)
5+
# License: MIT
6+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies (Patience)"
17+
$STD apt-get install -y \
18+
unzip \
19+
mariadb-server \
20+
apache2 \
21+
curl \
22+
sudo \
23+
php8.2-{mbstring,gd,fpm,curl,intl,ldap,tidy,bz2,mysql,zip,xml} \
24+
composer \
25+
libapache2-mod-php \
26+
make \
27+
mc
28+
msg_ok "Installed Dependencies"
29+
30+
msg_info "Setting up Database"
31+
DB_NAME=bookstack
32+
DB_USER=bookstack
33+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
34+
$STD sudo mysql -u root -e "CREATE DATABASE $DB_NAME;"
35+
$STD sudo mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
36+
$STD sudo mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
37+
{
38+
echo "Bookstack-Credentials"
39+
echo "Bookstack Database User: $DB_USER"
40+
echo "Bookstack Database Password: $DB_PASS"
41+
echo "Bookstack Database Name: $DB_NAME"
42+
} >> ~/bookstack.creds
43+
msg_ok "Set up database"
44+
45+
msg_info "Setup Bookstack (Patience)"
46+
LOCAL_IP="$(hostname -I | awk '{print $1}')"
47+
cd /opt
48+
RELEASE=$(curl -s https://api.github.com/repos/BookStackApp/BookStack/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
49+
wget -q "https://github.com/BookStackApp/BookStack/archive/refs/tags/v${RELEASE}.zip"
50+
unzip -q v${RELEASE}.zip
51+
mv BookStack-${RELEASE} /opt/bookstack
52+
cd /opt/bookstack
53+
cp .env.example .env
54+
sudo sed -i "s|APP_URL=.*|APP_URL=http://$LOCAL_IP|g" /opt/bookstack/.env
55+
sudo sed -i "s/DB_DATABASE=.*/DB_DATABASE=$DB_NAME/" /opt/bookstack/.env
56+
sudo sed -i "s/DB_USERNAME=.*/DB_USERNAME=$DB_USER/" /opt/bookstack/.env
57+
sudo sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$DB_PASS/" /opt/bookstack/.env
58+
$STD composer install --no-dev --no-plugins --no-interaction
59+
$STD php artisan key:generate --no-interaction --force
60+
$STD php artisan migrate --no-interaction --force
61+
chown www-data:www-data -R /opt/bookstack /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads /opt/bookstack/storage
62+
chmod -R 755 /opt/bookstack /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads /opt/bookstack/storage
63+
chmod -R 775 /opt/bookstack/storage /opt/bookstack/bootstrap/cache /opt/bookstack/public/uploads
64+
chmod -R 640 /opt/bookstack/.env
65+
$STD a2enmod rewrite
66+
$STD a2enmod php8.2
67+
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
68+
msg_ok "Installed Bookstack"
69+
70+
msg_info "Creating Service"
71+
cat <<EOF >/etc/apache2/sites-available/bookstack.conf
72+
<VirtualHost *:80>
73+
ServerAdmin webmaster@localhost
74+
DocumentRoot /opt/bookstack/public/
75+
76+
<Directory /opt/bookstack/public/>
77+
Options -Indexes +FollowSymLinks
78+
AllowOverride None
79+
Require all granted
80+
<IfModule mod_rewrite.c>
81+
<IfModule mod_negotiation.c>
82+
Options -MultiViews -Indexes
83+
</IfModule>
84+
85+
RewriteEngine On
86+
87+
# Handle Authorization Header
88+
RewriteCond %{HTTP:Authorization} .
89+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
90+
91+
# Redirect Trailing Slashes If Not A Folder...
92+
RewriteCond %{REQUEST_FILENAME} !-d
93+
RewriteCond %{REQUEST_URI} (.+)/$
94+
RewriteRule ^ %1 [L,R=301]
95+
96+
# Handle Front Controller...
97+
RewriteCond %{REQUEST_FILENAME} !-d
98+
RewriteCond %{REQUEST_FILENAME} !-f
99+
RewriteRule ^ index.php [L]
100+
</IfModule>
101+
</Directory>
102+
103+
ErrorLog /var/log/apache2/error.log
104+
CustomLog /var/log/apache2/access.log combined
105+
106+
</VirtualHost>
107+
EOF
108+
$STD a2ensite bookstack.conf
109+
$STD a2dissite 000-default.conf
110+
$STD systemctl reload apache2
111+
msg_ok "Created Services"
112+
113+
motd_ssh
114+
customize
115+
116+
msg_info "Cleaning up"
117+
rm -rf /opt/v${RELEASE}.zip
118+
$STD apt-get autoremove
119+
$STD apt-get autoclean
120+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)