Pangolin: Bump to 1.20.0 and harden SQLite migrations

Bump the default Pangolin version to 1.20.0 in both CT and install scripts. Update the CT upgrade path to validate required 1.20.0 schema objects, clear stale versionMigrations markers when needed, retry migrations once, and abort with a clear error if the schema is still incomplete to avoid a broken runtime.
This commit is contained in:
MickLesk
2026-07-10 14:44:32 +02:00
parent f4e0111ac0
commit 38423262c8
2 changed files with 50 additions and 4 deletions
+49 -3
View File
@@ -6,7 +6,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
# Source: https://pangolin.net/ | Github: https://github.com/fosrl/pangolin
APP="Pangolin"
PANGOLIN_VERSION="${PANGOLIN_VERSION:-1.18.4}"
PANGOLIN_VERSION="${PANGOLIN_VERSION:-1.20.0}"
var_tags="${var_tags:-proxy}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}"
@@ -80,15 +80,61 @@ function update_script() {
msg_ok "Updated pangolin.service"
fi
sqlite_table_exists() {
local db_path="$1"
local table_name="$2"
sqlite3 "$db_path" "SELECT 1 FROM sqlite_master WHERE type='table' AND name='$table_name' LIMIT 1;" 2>/dev/null | grep -q '^1$'
}
sqlite_column_exists() {
local db_path="$1"
local table_name="$2"
local column_name="$3"
sqlite3 "$db_path" "PRAGMA table_info('$table_name');" 2>/dev/null | awk -F'|' -v col="$column_name" '$2==col{found=1} END{exit !found}'
}
sqlite_schema_ready_for_120() {
local db_path="$1"
sqlite_table_exists "$db_path" "remoteExitNodePreferenceLabels" &&
sqlite_table_exists "$db_path" "remoteExitNodeResources" &&
sqlite_table_exists "$db_path" "launcherViews" &&
sqlite_column_exists "$db_path" "domains" "customCertResolver" &&
sqlite_column_exists "$db_path" "domains" "lastCheckedAt"
}
run_sqlite_migrations() {
ENVIRONMENT=prod $STD node dist/migrations.mjs
}
msg_info "Running database migrations"
cd /opt/pangolin
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
if ! sqlite_table_exists "$SQLITE_DB" "statusHistory"; then
sqlite3 "$SQLITE_DB" "DELETE FROM versionMigrations;" 2>/dev/null || true
fi
if [[ "$PANGOLIN_VERSION" == "1.20.0" ]] &&
sqlite3 "$SQLITE_DB" "SELECT 1 FROM versionMigrations WHERE version='1.20.0' LIMIT 1;" 2>/dev/null | grep -q '^1$' &&
! sqlite_schema_ready_for_120 "$SQLITE_DB"; then
msg_info "Detected stale migration marker for 1.20.0; forcing replay"
sqlite3 "$SQLITE_DB" "DELETE FROM versionMigrations WHERE version='1.20.0';" 2>/dev/null || true
fi
fi
ENVIRONMENT=prod $STD node dist/migrations.mjs
run_sqlite_migrations
if [[ -f "$SQLITE_DB" ]] && [[ "$PANGOLIN_VERSION" == "1.20.0" ]] && ! sqlite_schema_ready_for_120 "$SQLITE_DB"; then
msg_info "Schema check failed after first pass; retrying 1.20.0 migration"
sqlite3 "$SQLITE_DB" "DELETE FROM versionMigrations WHERE version='1.20.0';" 2>/dev/null || true
run_sqlite_migrations
fi
if [[ -f "$SQLITE_DB" ]] && [[ "$PANGOLIN_VERSION" == "1.20.0" ]] && ! sqlite_schema_ready_for_120 "$SQLITE_DB"; then
msg_error "SQLite schema is still incomplete after migration replay (expected 1.20.0 schema). Aborting update to prevent broken runtime."
exit 1
fi
msg_ok "Ran database migrations"
msg_info "Updating Badger plugin version"
+1 -1
View File
@@ -22,7 +22,7 @@ $STD apt install -y \
msg_ok "Installed Dependencies"
NODE_VERSION="24" setup_nodejs
PANGOLIN_VERSION="${PANGOLIN_VERSION:-1.18.4}"
PANGOLIN_VERSION="${PANGOLIN_VERSION:-1.20.0}"
fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball" "$PANGOLIN_VERSION"
fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_$(arch_resolve)"
fetch_and_deploy_gh_release "traefik" "traefik/traefik" "prebuild" "latest" "/usr/bin" "traefik_v*_linux_$(arch_resolve).tar.gz"