This commit is contained in:
Slaviša Arežina
2025-11-02 20:53:05 +01:00
committed by GitHub
parent 95c17ad8a4
commit 077c866399
2 changed files with 20 additions and 27 deletions

View File

@@ -32,35 +32,26 @@ function update_script() {
if check_for_gh_release "pangolin" "fosrl/pangolin"; then if check_for_gh_release "pangolin" "fosrl/pangolin"; then
msg_info "Stopping Service" msg_info "Stopping Service"
systemctl stop pangolin systemctl stop pangolin
systemctl stop gerbil
msg_info "Service stopped" msg_info "Service stopped"
msg_info "Creating backup" msg_info "Creating backup"
tar -czf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin config tar -czf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin config
msg_ok "Created backup" msg_ok "Created backup"
fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball"
fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64"
msg_info "Updating Pangolin" msg_info "Updating Pangolin"
export BUILD=oss
export DATABASE=sqlite
cd /opt/pangolin cd /opt/pangolin
$STD npm ci $STD npm ci
echo "export * from \"./$DATABASE\";" > server/db/index.ts $STD npm run set:sqlite
echo "export const build = \"$BUILD\" as any;" > server/build.ts $STD npm run set:oss
cp tsconfig.oss.json tsconfig.json rm -rf server/private
$STD npm run next:build $STD npm run build:sqlite
$STD node esbuild.mjs -e server/index.ts -o dist/server.mjs -b $BUILD
$STD node esbuild.mjs -e server/setup/migrationsSqlite.ts -o dist/migrations.mjs
$STD npm run build:cli $STD npm run build:cli
cp -R .next/standalone ./ cp -R .next/standalone ./
chmod +x ./dist/cli.mjs
cat <<EOF >/usr/local/bin/pangctl
#!/bin/sh
cd /opt/pangolin
./dist/cli.mjs "$@"
EOF
chmod +x /usr/local/bin/pangctl ./dist/cli.mjs
cp server/db/names.json ./dist/names.json cp server/db/names.json ./dist/names.json
msg_ok "Updated Pangolin" msg_ok "Updated Pangolin"
@@ -68,6 +59,11 @@ EOF
tar -xzf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin --overwrite tar -xzf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin --overwrite
rm -f /opt/pangolin_config_backup.tar.gz rm -f /opt/pangolin_config_backup.tar.gz
msg_ok "Restored config" msg_ok "Restored config"
msg_info "Starting Services"
systemctl start pangolin
systemctl start gerbil
msg_ok "Started Services"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
fi fi
exit exit

View File

@@ -26,17 +26,12 @@ fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/
msg_info "Setup Pangolin" msg_info "Setup Pangolin"
IP_ADDR=$(hostname -I | awk '{print $1}') IP_ADDR=$(hostname -I | awk '{print $1}')
SECRET_KEY=$(openssl rand -base64 48 | tr -dc 'A-Za-z0-9' | head -c 32) SECRET_KEY=$(openssl rand -base64 48 | tr -dc 'A-Za-z0-9' | head -c 32)
export BUILD=oss
export DATABASE=sqlite
cd /opt/pangolin cd /opt/pangolin
$STD npm ci $STD npm ci
echo "export * from \"./$DATABASE\";" > server/db/index.ts $STD npm run set:sqlite
echo "export const build = \"$BUILD\" as any;" > server/build.ts $STD npm run set:oss
cp tsconfig.oss.json tsconfig.json rm -rf server/private
mkdir -p dist $STD npm run build:sqlite
$STD npm run next:build
$STD node esbuild.mjs -e server/index.ts -o dist/server.mjs -b $BUILD
$STD node esbuild.mjs -e server/setup/migrationsSqlite.ts -o dist/migrations.mjs
$STD npm run build:cli $STD npm run build:cli
cp -R .next/standalone ./ cp -R .next/standalone ./
@@ -98,8 +93,10 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
User=root User=root
Environment=NODE_ENV=production
Environment=ENVIRONMENT=prod
WorkingDirectory=/opt/pangolin WorkingDirectory=/opt/pangolin
ExecStart=/usr/bin/npm start ExecStart=/usr/bin/node --enable-source-maps dist/server.mjs
Restart=always Restart=always
RestartSec=10 RestartSec=10