Update PatchMon

This commit is contained in:
vhsdream 2025-10-24 09:11:57 -04:00
parent dc804416b0
commit 05f56e9ef1
2 changed files with 19 additions and 19 deletions

View File

@ -47,14 +47,11 @@ function update_script() {
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
cd /opt/patchmon cd /opt/patchmon
export NODE_ENV=production export NODE_ENV=production
export NPM_CONFIG_CACHE=/opt/patchmon/.npm
export NPM_CONFIG_PREFIX=/opt/patchmon/.npm-global
export NPM_CONFIG_TMP=/opt/patchmon/.npm/tmp
$STD npm install --omit=dev --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/backend
$STD npm install --omit=dev --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/frontend
$STD npm install --no-audit --no-fund --no-save --ignore-scripts $STD npm install --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/backend
$STD npm install --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/frontend
$STD npm install --include=dev --no-audit --no-fund --no-save --ignore-scripts
$STD npm run build $STD npm run build
cd /opt/patchmon/backend cd /opt/patchmon/backend
$STD npx prisma migrate deploy $STD npx prisma migrate deploy

View File

@ -46,15 +46,11 @@ fetch_and_deploy_gh_release "PatchMon" "PatchMon/PatchMon" "tarball" "latest" "/
msg_info "Configuring PatchMon" msg_info "Configuring PatchMon"
cd /opt/patchmon cd /opt/patchmon
export NODE_ENV=production export NODE_ENV=production
export NPM_CONFIG_CACHE=/opt/patchmon/.npm $STD npm install --no-audit --no-fund --no-save --ignore-scripts
export NPM_CONFIG_PREFIX=/opt/patchmon/.npm-global
export NPM_CONFIG_TMP=/opt/patchmon/.npm/tmp
$STD npm install --omit=dev --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/backend cd /opt/patchmon/backend
$STD npm install --omit=dev --no-audit --no-fund --no-save --ignore-scripts $STD npm install --no-audit --no-fund --no-save --ignore-scripts
cd /opt/patchmon/frontend cd /opt/patchmon/frontend
export npm_config_production=false $STD npm install --include=dev --no-audit --no-fund --no-save --ignore-scripts
$STD npm install --no-audit --no-fund --no-save
$STD npm run build $STD npm run build
msg_ok "Configured PatchMon" msg_ok "Configured PatchMon"
@ -156,11 +152,11 @@ server {
proxy_cache_bypass \$http_upgrade; proxy_cache_bypass \$http_upgrade;
proxy_read_timeout 300s; proxy_read_timeout 300s;
proxy_connect_timeout 75s; proxy_connect_timeout 75s;
# Enable cookie passthrough # Enable cookie passthrough
proxy_pass_header Set-Cookie; proxy_pass_header Set-Cookie;
proxy_cookie_path / /; proxy_cookie_path / /;
# Preserve original client IP # Preserve original client IP
proxy_set_header X-Original-Forwarded-For \$http_x_forwarded_for; proxy_set_header X-Original-Forwarded-For \$http_x_forwarded_for;
if (\$request_method = 'OPTIONS') { if (\$request_method = 'OPTIONS') {
@ -181,7 +177,7 @@ server {
proxy_cache_bypass \$http_upgrade; proxy_cache_bypass \$http_upgrade;
proxy_read_timeout 300s; proxy_read_timeout 300s;
proxy_connect_timeout 75s; proxy_connect_timeout 75s;
# Preserve original client IP # Preserve original client IP
proxy_set_header X-Original-Forwarded-For \$http_x_forwarded_for; proxy_set_header X-Original-Forwarded-For \$http_x_forwarded_for;
if (\$request_method = 'OPTIONS') { if (\$request_method = 'OPTIONS') {
@ -195,7 +191,7 @@ server {
expires 1y; expires 1y;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
} }
# Health check endpoint # Health check endpoint
location /health { location /health {
proxy_pass http://127.0.0.1:3399/health; proxy_pass http://127.0.0.1:3399/health;
@ -238,17 +234,24 @@ msg_ok "Created and started service"
msg_info "Populating server settings in DB" msg_info "Populating server settings in DB"
cat <<EOF >/opt/patchmon/backend/update-settings.js cat <<EOF >/opt/patchmon/backend/update-settings.js
const { PrismaClient } = require('@prisma/client'); const { PrismaClient } = require('@prisma/client');
const { v4: uuidv4 } = require('uuid');
const prisma = new PrismaClient(); const prisma = new PrismaClient();
async function updateSettings() { async function updateSettings() {
try { try {
const existingSettings = await prisma.settings.findFirst();
const settingsData = { const settingsData = {
id: uuidv4(),
server_url: 'http://$LOCAL_IP', server_url: 'http://$LOCAL_IP',
server_protocol: 'http', server_protocol: 'http',
server_host: '$LOCAL_IP', server_host: '$LOCAL_IP',
server_port: 3399, server_port: 3399,
update_interval: 60, update_interval: 60,
auto_update: true auto_update: true,
signup_enabled: false,
ignore_ssl_self_signed: false,
updated_at: new Date()
}; };
if (existingSettings) { if (existingSettings) {