mirror of https://github.com/tteck/Proxmox
Compare commits
16 Commits
612979a040
...
5ae25108ef
Author | SHA1 | Date |
---|---|---|
|
5ae25108ef | 9 months ago |
|
55c8d1187b | 9 months ago |
|
9a5d43e4d3 | 9 months ago |
|
bb2c143cc8 | 9 months ago |
|
2a844122d0 | 9 months ago |
|
540fcd24f2 | 9 months ago |
|
c2c48b52c7 | 9 months ago |
|
744e183eea | 9 months ago |
|
468a5d367d | 9 months ago |
|
edf0753120 | 9 months ago |
|
64eab60a4c | 9 months ago |
|
5c711293b9 | 9 months ago |
|
1d83562661 | 9 months ago |
|
f5978717d4 | 9 months ago |
|
7176eaa99d | 9 months ago |
|
2184eab0c5 | 9 months ago |
10 changed files with 522 additions and 37 deletions
@ -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" |
@ -0,0 +1,99 @@ |
||||
#!/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="Wallos" |
||||
var_disk="5" |
||||
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/wallos ]]; 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/ellite/Wallos/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 "Updating ${APP} to ${RELEASE}" |
||||
cd /opt |
||||
wget -q "https://github.com/ellite/Wallos/archive/refs/tags/v${RELEASE}.zip" |
||||
mv /opt/wallos/db/wallos.db /opt/wallos.db |
||||
unzip -q v${RELEASE}.zip |
||||
mv Wallos-${RELEASE} /opt/wallos |
||||
rm -rf /opt/wallos/db/wallos.empty.db |
||||
mv /opt/wallos.db /opt/wallos/db/wallos.db |
||||
chown -R www-data:www-data /opt/wallos |
||||
chmod -R 755 /opt/wallos |
||||
curl http://localhost/endpoints/db/migrate.php &>/dev/null |
||||
echo "${RELEASE}" >/opt/${APP}_version.txt |
||||
msg_ok "Updated ${APP}" |
||||
|
||||
msg_info "Reload Apache2" |
||||
systemctl reload apache2 |
||||
msg_ok "Apache2 Reloaded" |
||||
|
||||
msg_info "Cleaning Up" |
||||
rm -R /opt/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} should be reachable by going to the following URL. |
||||
${BL}http://${IP} ${CL} \n" |
@ -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" |
@ -0,0 +1,81 @@ |
||||
#!/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/ellite/wallos |
||||
|
||||
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 \ |
||||
curl \ |
||||
sudo \ |
||||
mc \ |
||||
apache2 \ |
||||
libapache2-mod-php \ |
||||
php8.2-{mbstring,gd,curl,intl,imagick,bz2,sqlite3,zip,xml} |
||||
msg_ok "Installed Dependencies" |
||||
|
||||
msg_info "Installing Wallos (Patience)" |
||||
cd /opt |
||||
RELEASE=$(curl -s https://api.github.com/repos/ellite/Wallos/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
||||
wget -q "https://github.com/ellite/Wallos/archive/refs/tags/v${RELEASE}.zip" |
||||
unzip -q v${RELEASE}.zip |
||||
mv Wallos-${RELEASE} /opt/wallos |
||||
cd /opt/wallos |
||||
mv /opt/wallos/db/wallos.empty.db /opt/wallos/db/wallos.db |
||||
chown -R www-data:www-data /opt/wallos |
||||
chmod -R 755 /opt/wallos |
||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" |
||||
|
||||
cat <<EOF >/etc/apache2/sites-available/wallos.conf |
||||
<VirtualHost *:80> |
||||
ServerAdmin webmaster@localhost |
||||
DocumentRoot /opt/wallos |
||||
|
||||
<Directory /opt/wallos> |
||||
Options Indexes FollowSymLinks |
||||
AllowOverride All |
||||
Require all granted |
||||
</Directory> |
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/wallos_error.log |
||||
CustomLog \${APACHE_LOG_DIR}/wallos_access.log combined |
||||
</VirtualHost> |
||||
EOF |
||||
$STD a2ensite wallos.conf |
||||
$STD a2dissite 000-default.conf |
||||
$STD systemctl reload apache2 |
||||
$STD curl http://localhost/endpoints/db/migrate.php |
||||
msg_ok "Installed Wallos" |
||||
|
||||
msg_info "Setting up Crontabs" |
||||
cat <<EOF > /opt/wallos.cron |
||||
0 1 * * * php /opt/wallos/endpoints/cronjobs/updatenextpayment.php >> /var/log/cron/updatenextpayment.log 2>&1 |
||||
0 2 * * * php /opt/wallos/endpoints/cronjobs/updateexchange.php >> /var/log/cron/updateexchange.log 2>&1 |
||||
0 8 * * * php /opt/wallos/endpoints/cronjobs/sendcancellationnotifications.php >> /var/log/cron/sendcancellationnotifications.log 2>&1 |
||||
0 9 * * * php /opt/wallos/endpoints/cronjobs/sendnotifications.php >> /var/log/cron/sendnotifications.log 2>&1 |
||||
*/2 * * * * php /opt/wallos/endpoints/cronjobs/sendverificationemails.php >> /var/log/cron/sendverificationemail.log 2>&1 |
||||
*/2 * * * * php /opt/wallos/endpoints/cronjobs/sendresetpasswordemails.php >> /var/log/cron/sendresetpasswordemails.log 2>&1 |
||||
0 */6 * * * php /opt/wallos/endpoints/cronjobs/checkforupdates.php >> /var/log/cron/checkforupdates.log 2>&1 |
||||
EOF |
||||
crontab /opt/wallos.cron |
||||
msg_ok "Crontabs setup" |
||||
|
||||
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