mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-22 00:04:13 +01:00
Add new LXC: AdventureLog (#3971)
This commit is contained in:
parent
55c8d1187b
commit
5ae25108ef
110
ct/adventurelog.sh
Normal file
110
ct/adventurelog.sh
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2024 tteck
|
||||||
|
# Author: tteck
|
||||||
|
# Co-Author: MickLesk (Canbiz)
|
||||||
|
# License: MIT
|
||||||
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
|
function header_info {
|
||||||
|
clear
|
||||||
|
cat <<"EOF"
|
||||||
|
___ __ __ __
|
||||||
|
/ | ____/ / _____ ____ / /___ __________ / / ____ ____ _
|
||||||
|
/ /| |/ __ / | / / _ \/ __ \/ __/ / / / ___/ _ \/ / / __ \/ __ `/
|
||||||
|
/ ___ / /_/ /| |/ / __/ / / / /_/ /_/ / / / __/ /___/ /_/ / /_/ /
|
||||||
|
/_/ |_\__,_/ |___/\___/_/ /_/\__/\__,_/_/ \___/_____/\____/\__, /
|
||||||
|
/____/
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
header_info
|
||||||
|
echo -e "Loading..."
|
||||||
|
APP="AdventureLog"
|
||||||
|
var_disk="7"
|
||||||
|
var_cpu="2"
|
||||||
|
var_ram="2048"
|
||||||
|
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/adventurelog ]]; 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/seanmorley15/AdventureLog/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 Services"
|
||||||
|
systemctl stop adventurelog-backend
|
||||||
|
systemctl stop adventurelog-frontend
|
||||||
|
msg_ok "Services Stopped"
|
||||||
|
|
||||||
|
msg_info "Updating ${APP} to ${RELEASE}"
|
||||||
|
cp /opt/adventurelog/backend/server/.env /opt/server.env
|
||||||
|
cp /opt/adventurelog/frontend/env /opt/frontend.env
|
||||||
|
wget -q "https://github.com/seanmorley15/AdventureLog/archive/refs/tags/v${RELEASE}.zip"
|
||||||
|
unzip -q v${RELEASE}.zip
|
||||||
|
mv AdventureLog-${RELEASE} /opt/adventurelog
|
||||||
|
mv /opt/server.env /opt/adventurelog/backend/server/.env
|
||||||
|
cd /opt/adventurelog/backend/server
|
||||||
|
pip install --upgrade pip &>/dev/null
|
||||||
|
pip install -r requirements.txt &>/dev/null
|
||||||
|
python3 manage.py collectstatic --noinput &>/dev/null
|
||||||
|
python3 manage.py migrate &>/dev/null
|
||||||
|
|
||||||
|
mv /opt/frontend.env /opt/adventurelog/frontend/.env
|
||||||
|
cd /opt/adventurelog/frontend
|
||||||
|
pnpm install &>/dev/null
|
||||||
|
pnpm run build &>/dev/null
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
|
msg_ok "Updated ${APP}"
|
||||||
|
|
||||||
|
msg_info "Starting Services"
|
||||||
|
systemctl start adventurelog-backend
|
||||||
|
systemctl start adventurelog-frontend
|
||||||
|
msg_ok "Started Services"
|
||||||
|
|
||||||
|
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}:3000${CL} \n"
|
175
install/adventurelog-install.sh
Normal file
175
install/adventurelog-install.sh
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2024 tteck
|
||||||
|
# Author: tteck
|
||||||
|
# Co-Author: MickLesk (Canbiz)
|
||||||
|
# License: MIT
|
||||||
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/seanmorley15/AdventureLog
|
||||||
|
|
||||||
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
gpg \
|
||||||
|
curl \
|
||||||
|
sudo \
|
||||||
|
mc \
|
||||||
|
gdal-bin \
|
||||||
|
libgdal-dev \
|
||||||
|
git \
|
||||||
|
python3-venv \
|
||||||
|
python3-pip
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Setting up Node.js Repository"
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
|
||||||
|
msg_ok "Set up Node.js Repository"
|
||||||
|
|
||||||
|
msg_info "Setting up PostgreSQL Repository"
|
||||||
|
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
|
||||||
|
echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list
|
||||||
|
msg_ok "Set up PostgreSQL Repository"
|
||||||
|
|
||||||
|
msg_info "Installing Node.js"
|
||||||
|
$STD apt-get update
|
||||||
|
$STD apt-get install -y nodejs
|
||||||
|
$STD npm install -g pnpm
|
||||||
|
msg_ok "Installed Node.js"
|
||||||
|
|
||||||
|
msg_info "Install/Set up PostgreSQL Database"
|
||||||
|
$STD apt-get install -y postgresql-16 postgresql-16-postgis
|
||||||
|
DB_NAME="adventurelog_db"
|
||||||
|
DB_USER="adventurelog_user"
|
||||||
|
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
|
||||||
|
SECRET_KEY="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)"
|
||||||
|
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
|
||||||
|
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
|
||||||
|
$STD sudo -u postgres psql -c "CREATE EXTENSION IF NOT EXISTS postgis;" $DB_NAME
|
||||||
|
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
|
||||||
|
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
|
||||||
|
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
|
||||||
|
{
|
||||||
|
echo "AdventureLog-Credentials"
|
||||||
|
echo "AdventureLog Database User: $DB_USER"
|
||||||
|
echo "AdventureLog Database Password: $DB_PASS"
|
||||||
|
echo "AdventureLog Database Name: $DB_NAME"
|
||||||
|
echo "AdventureLog Secret: $SECRET_KEY"
|
||||||
|
} >> ~/adventurelog.creds
|
||||||
|
msg_ok "Set up PostgreSQL"
|
||||||
|
|
||||||
|
msg_info "Installing AdventureLog (Patience)"
|
||||||
|
DJANGO_ADMIN_USER="djangoadmin"
|
||||||
|
DJANGO_ADMIN_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
|
||||||
|
LOCAL_IP="$(hostname -I | awk '{print $1}')"
|
||||||
|
cd /opt
|
||||||
|
RELEASE=$(curl -s https://api.github.com/repos/seanmorley15/AdventureLog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
|
wget -q "https://github.com/seanmorley15/AdventureLog/archive/refs/tags/v${RELEASE}.zip"
|
||||||
|
unzip -q v${RELEASE}.zip
|
||||||
|
mv AdventureLog-${RELEASE} /opt/adventurelog
|
||||||
|
cat <<EOF > /opt/adventurelog/backend/server/.env
|
||||||
|
PGHOST='localhost'
|
||||||
|
PGDATABASE='${DB_NAME}'
|
||||||
|
PGUSER='${DB_USER}'
|
||||||
|
PGPASSWORD='${DB_PASS}'
|
||||||
|
SECRET_KEY='${SECRET_KEY}'
|
||||||
|
PUBLIC_URL='http://$LOCAL_IP:8000'
|
||||||
|
DEBUG=True
|
||||||
|
FRONTEND_URL='http://$LOCAL_IP:3000'
|
||||||
|
CSRF_TRUSTED_ORIGINS='http://127.0.0.1:3000,http://localhost:3000,http://$LOCAL_IP:3000'
|
||||||
|
DJANGO_ADMIN_USERNAME='${DJANGO_ADMIN_USER}'
|
||||||
|
DJANGO_ADMIN_PASSWORD='${DJANGO_ADMIN_PASS}'
|
||||||
|
DISABLE_REGISTRATION=False
|
||||||
|
# EMAIL_BACKEND='email'
|
||||||
|
# EMAIL_HOST='smtp.gmail.com'
|
||||||
|
# EMAIL_USE_TLS=False
|
||||||
|
# EMAIL_PORT=587
|
||||||
|
# EMAIL_USE_SSL=True
|
||||||
|
# EMAIL_HOST_USER='user'
|
||||||
|
# EMAIL_HOST_PASSWORD='password'
|
||||||
|
# DEFAULT_FROM_EMAIL='user@example.com'
|
||||||
|
EOF
|
||||||
|
cd /opt/adventurelog/backend/server
|
||||||
|
mkdir -p /opt/adventurelog/backend/server/media
|
||||||
|
$STD pip install --upgrade pip
|
||||||
|
$STD pip install -r requirements.txt
|
||||||
|
$STD python3 manage.py collectstatic --noinput
|
||||||
|
$STD python3 manage.py migrate
|
||||||
|
$STD python3 manage.py download-countries
|
||||||
|
cat <<EOF > /opt/adventurelog/frontend/.env
|
||||||
|
PUBLIC_SERVER_URL=http://$LOCAL_IP:8000
|
||||||
|
BODY_SIZE_LIMIT=Infinity
|
||||||
|
ORIGIN='http://$LOCAL_IP:3000'
|
||||||
|
EOF
|
||||||
|
cd /opt/adventurelog/frontend
|
||||||
|
$STD pnpm i
|
||||||
|
$STD pnpm build
|
||||||
|
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||||
|
msg_ok "Installed AdventureLog"
|
||||||
|
|
||||||
|
msg_info "Setting up Django Admin"
|
||||||
|
$STD python3 /opt/adventurelog/backend/server/manage.py shell << EOF
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
UserModel = get_user_model()
|
||||||
|
user = UserModel.objects.create_user('$DJANGO_ADMIN_USER', password='$DJANGO_ADMIN_PASS')
|
||||||
|
user.is_superuser = True
|
||||||
|
user.is_staff = True
|
||||||
|
user.save()
|
||||||
|
EOF
|
||||||
|
{
|
||||||
|
echo ""
|
||||||
|
echo "Django-Credentials"
|
||||||
|
echo "Django Admin User: $DJANGO_ADMIN_USER"
|
||||||
|
echo "Django Admin Password: $DJANGO_ADMIN_PASS"
|
||||||
|
} >> ~/adventurelog.creds
|
||||||
|
msg_ok "Setup Django Admin"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/adventurelog-backend.service
|
||||||
|
[Unit]
|
||||||
|
Description=AdventureLog Backend Service
|
||||||
|
After=network.target postgresql.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/adventurelog/backend/server
|
||||||
|
ExecStart=python3 manage.py runserver 0.0.0.0:8000
|
||||||
|
Restart=always
|
||||||
|
EnvironmentFile=/opt/adventurelog/backend/server/.env
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
cat <<EOF >/etc/systemd/system/adventurelog-frontend.service
|
||||||
|
[Unit]
|
||||||
|
Description=AdventureLog SvelteKit Frontend Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/adventurelog/frontend
|
||||||
|
ExecStart=/usr/bin/node build 127.0.0.1:3000
|
||||||
|
Restart=always
|
||||||
|
EnvironmentFile=/opt/adventurelog/frontend/.env
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now adventurelog-backend.service
|
||||||
|
systemctl enable -q --now adventurelog-frontend.service
|
||||||
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
rm -rf /opt/v${RELEASE}.zip
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
Loading…
Reference in New Issue
Block a user