2025-11-01 20:06:45 +01:00
#!/usr/bin/env bash
source <( curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
2026-01-06 13:28:12 +01:00
# Copyright (c) 2021-2026 community-scripts ORG
2025-11-01 20:06:45 +01:00
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
2026-02-24 15:11:53 +01:00
# Source: https://pangolin.net/ | Github: https://github.com/fosrl/pangolin
2025-11-01 20:06:45 +01:00
APP = "Pangolin"
2026-05-18 20:01:55 +02:00
PANGOLIN_VERSION = " ${ PANGOLIN_VERSION :- 1 .18.4 } "
2025-11-01 20:06:45 +01:00
var_tags = " ${ var_tags :- proxy } "
var_cpu = " ${ var_cpu :- 2 } "
var_ram = " ${ var_ram :- 4096 } "
2026-02-28 14:45:59 +01:00
var_disk = " ${ var_disk :- 10 } "
2025-11-01 20:06:45 +01:00
var_os = " ${ var_os :- debian } "
var_version = " ${ var_version :- 13 } "
2026-05-23 07:46:44 +10:00
var_arm64 = " ${ var_arm64 :- no } "
2025-11-01 20:06:45 +01:00
var_unprivileged = " ${ var_unprivileged :- 1 } "
var_tun = " ${ var_tun :- 1 } "
header_info " $APP "
variables
color
catch_errors
function update_script() {
2025-11-07 14:59:34 +01:00
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/pangolin ]] ; then
msg_error "No ${ APP } Installation Found!"
exit
fi
2025-11-01 20:06:45 +01:00
2026-02-28 10:21:39 +01:00
ensure_dependencies build-essential python3
2026-02-24 11:38:15 +01:00
NODE_VERSION = "24" setup_nodejs
2026-05-03 22:30:21 +02:00
if check_for_gh_release "pangolin" "fosrl/pangolin" " $PANGOLIN_VERSION " "Pinned to a tested release because Pangolin's schema changes have repeatedly broken unattended updates. To try a newer version at your own risk, run: 'export PANGOLIN_VERSION=<tag>' and re-run update. If it breaks, please open an issue at https://github.com/community-scripts/ProxmoxVE/issues with the error log." ; then
2025-11-07 14:59:34 +01:00
msg_info "Stopping Service"
systemctl stop pangolin
systemctl stop gerbil
msg_info "Service stopped"
2025-11-01 20:06:45 +01:00
2025-11-07 14:59:34 +01:00
msg_info "Creating backup"
tar -czf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin config
2026-05-03 22:30:21 +02:00
if [[ -f /opt/pangolin/config/db/db.sqlite ]] ; then
cp -a /opt/pangolin/config/db/db.sqlite \
"/opt/pangolin/config/db/db.sqlite.pre- ${ PANGOLIN_VERSION } - $( date +%Y%m%d-%H%M%S) .bak"
fi
2025-11-07 14:59:34 +01:00
msg_ok "Created backup"
2025-11-01 20:06:45 +01:00
2026-05-03 22:30:21 +02:00
CLEAN_INSTALL = 1 fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball" " $PANGOLIN_VERSION "
2025-11-07 14:59:34 +01:00
CLEAN_INSTALL = 1 fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64"
2025-11-01 20:06:45 +01:00
2025-11-07 14:59:34 +01:00
msg_info "Updating Pangolin"
cd /opt/pangolin
$STD npm ci
$STD npm run set:sqlite
$STD npm run set:oss
rm -rf server/private
2026-02-06 14:25:44 +01:00
$STD npm run db:generate
$STD npm run build
2025-11-07 14:59:34 +01:00
$STD npm run build:cli
cp -R .next/standalone ./
chmod +x ./dist/cli.mjs
cp server/db/names.json ./dist/names.json
2026-01-25 15:01:31 -05:00
cp server/db/ios_models.json ./dist/ios_models.json
cp server/db/mac_models.json ./dist/mac_models.json
2025-11-07 14:59:34 +01:00
msg_ok "Updated Pangolin"
2025-11-01 20:06:45 +01:00
2025-11-07 14:59:34 +01:00
msg_info "Restoring config"
tar -xzf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin --overwrite
rm -f /opt/pangolin_config_backup.tar.gz
msg_ok "Restored config"
2025-11-02 20:53:05 +01:00
2026-05-03 22:30:21 +02:00
if ! grep -q '^ExecStartPre=/usr/bin/node dist/migrations.mjs' /etc/systemd/system/pangolin.service 2>/dev/null; then
msg_info "Adding migration step to pangolin.service"
sed -i '/^ExecStart=\/usr\/bin\/node --enable-source-maps dist\/server.mjs/i ExecStartPre=/usr/bin/node dist/migrations.mjs' /etc/systemd/system/pangolin.service
systemctl daemon-reload
msg_ok "Updated pangolin.service"
2026-04-20 09:21:54 +02:00
fi
2026-05-03 22:30:21 +02:00
msg_info "Running database migrations"
cd /opt/pangolin
2026-05-18 20:01:55 +02:00
SQLITE_DB = "/opt/pangolin/config/db/db.sqlite"
if [[ -f " $SQLITE_DB " ]] ; then
if ! sqlite3 " $SQLITE_DB " ".tables" 2>/dev/null | tr ' ' '\n' | grep -qx "statusHistory" ; then
sqlite3 " $SQLITE_DB " "DELETE FROM versionMigrations;" 2>/dev/null || true
fi
fi
2026-05-03 22:30:21 +02:00
ENVIRONMENT = prod $STD node dist/migrations.mjs
2026-02-21 14:48:22 +01:00
msg_ok "Ran database migrations"
2026-01-19 22:41:01 +01:00
msg_info "Updating Badger plugin version"
BADGER_VERSION = $( get_latest_github_release "fosrl/badger" "false" )
sed -i "s/version: \"v[0-9.]*\"/version: \" $BADGER_VERSION \"/g" /opt/pangolin/config/traefik/traefik_config.yml
msg_ok "Updated Badger plugin version"
2025-11-07 14:59:34 +01:00
msg_info "Starting Services"
systemctl start pangolin
systemctl start gerbil
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit
2025-11-01 20:06:45 +01:00
}
start
build_container
description
2026-01-06 22:57:40 +01:00
msg_ok "Completed successfully!\n"
2025-11-01 20:06:45 +01:00
echo -e " ${ CREATING }${ GN }${ APP } setup has been successfully initialized! ${ CL } "
2026-06-03 11:03:13 +02:00
echo -e " ${ INFO }${ YW } Access it using the following URL: ${ CL } "
echo -e " ${ GATEWAY }${ BGN } https://<YOUR_PANGOLIN_URL> ${ CL } "