mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-18 06:02:36 -04:00
Compare commits
1 Commits
github-act
...
geopulse-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5a1c26416 |
@@ -10,7 +10,7 @@ APP="GeoPulse"
|
||||
var_tags="${var_tags:-location;tracking;gps}"
|
||||
var_cpu="${var_cpu:-2}"
|
||||
var_ram="${var_ram:-1024}"
|
||||
var_disk="${var_disk:-8}"
|
||||
var_disk="${var_disk:-12}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-13}"
|
||||
var_arm64="${var_arm64:-yes}"
|
||||
@@ -32,6 +32,16 @@ function update_script() {
|
||||
fi
|
||||
|
||||
if check_for_gh_release "geopulse-backend" "tess1o/geopulse"; then
|
||||
msg_info "Backing Up Database"
|
||||
mkdir -p /var/lib/geopulse/dumps
|
||||
DB_NAME="$(grep -oP '^GEOPULSE_POSTGRES_DB=\K.*' /etc/geopulse/geopulse.env 2>/dev/null)"
|
||||
DB_NAME="${DB_NAME:-geopulse}"
|
||||
if sudo -u postgres pg_dump -Fc "${DB_NAME}" >"/var/lib/geopulse/dumps/${DB_NAME}-pre-update-$(date +%Y%m%d%H%M%S).dump" 2>/dev/null; then
|
||||
msg_ok "Backed Up Database"
|
||||
else
|
||||
msg_warn "Database backup failed, continuing anyway"
|
||||
fi
|
||||
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop geopulse-backend
|
||||
msg_ok "Stopped Service"
|
||||
@@ -51,7 +61,48 @@ function update_script() {
|
||||
fi
|
||||
|
||||
fetch_and_deploy_gh_release "geopulse-backend" "tess1o/geopulse" "singlefile" "latest" "/opt/geopulse/backend" "${BINARY_PATTERN}"
|
||||
fetch_and_deploy_gh_release "geopulse-frontend" "tess1o/geopulse" "prebuild" "latest" "/var/www/geopulse" "geopulse-frontend-*.tar.gz"
|
||||
CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP="avatars" fetch_and_deploy_gh_release "geopulse-frontend" "tess1o/geopulse" "prebuild" "latest" "/var/www/geopulse" "geopulse-frontend-*.tar.gz"
|
||||
|
||||
if [[ -f /etc/geopulse/geopulse.env ]] && grep -q "GEOPULSE_JWT_" /etc/geopulse/geopulse.env 2>/dev/null; then
|
||||
msg_info "Removing Unused JWT Keys"
|
||||
sed -i '/^GEOPULSE_JWT_PRIVATE_KEY_LOCATION=/d;/^GEOPULSE_JWT_PUBLIC_KEY_LOCATION=/d' /etc/geopulse/geopulse.env
|
||||
rm -f /opt/geopulse/keys/jwt-private-key.pem /opt/geopulse/keys/jwt-public-key.pem
|
||||
msg_ok "Removed Unused JWT Keys"
|
||||
fi
|
||||
|
||||
if [[ -f /etc/nginx/sites-available/geopulse.conf ]] && ! grep -q '\.mjs\$' /etc/nginx/sites-available/geopulse.conf; then
|
||||
msg_info "Configuring Nginx for .mjs Assets"
|
||||
cp /etc/nginx/sites-available/geopulse.conf /etc/nginx/sites-available/geopulse.conf.pre-mjs.bak
|
||||
|
||||
ANCHOR_LINE="$(grep -n ' add_header Cache-Control "public, max-age=31536000";' /etc/nginx/sites-available/geopulse.conf.pre-mjs.bak | head -1 | cut -d: -f1)"
|
||||
|
||||
if [[ -n "$ANCHOR_LINE" ]]; then
|
||||
INSERT_LINE=$((ANCHOR_LINE + 1))
|
||||
{
|
||||
head -n "$INSERT_LINE" /etc/nginx/sites-available/geopulse.conf.pre-mjs.bak
|
||||
cat <<'MJSBLOCK'
|
||||
|
||||
location ~* ^/(?!osm/).*\.mjs$ {
|
||||
types {
|
||||
application/javascript mjs;
|
||||
}
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, max-age=31536000";
|
||||
}
|
||||
MJSBLOCK
|
||||
tail -n "+$((INSERT_LINE + 1))" /etc/nginx/sites-available/geopulse.conf.pre-mjs.bak
|
||||
} >/etc/nginx/sites-available/geopulse.conf
|
||||
fi
|
||||
|
||||
if [[ -n "$ANCHOR_LINE" ]] && grep -q '\.mjs\$' /etc/nginx/sites-available/geopulse.conf && nginx -t >/dev/null 2>&1; then
|
||||
systemctl reload nginx
|
||||
msg_ok "Configured Nginx for .mjs Assets"
|
||||
else
|
||||
cp /etc/nginx/sites-available/geopulse.conf.pre-mjs.bak /etc/nginx/sites-available/geopulse.conf
|
||||
nginx -t >/dev/null 2>&1 && systemctl reload nginx
|
||||
msg_warn "Could not automatically add the .mjs nginx block (customized config?) - add it manually, see the GeoPulse 2.0.0 upgrade notes"
|
||||
fi
|
||||
fi
|
||||
|
||||
msg_info "Starting Service"
|
||||
systemctl start geopulse-backend
|
||||
|
||||
@@ -19,17 +19,15 @@ $STD apt install -y \
|
||||
nginx
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
PG_VERSION="17" PG_MODULES="postgis" setup_postgresql
|
||||
PG_VERSION="18" PG_MODULES="postgis" setup_postgresql
|
||||
PG_DB_NAME="geopulse" PG_DB_USER="geopulse" PG_DB_EXTENSIONS="postgis,postgis_topology" setup_postgresql_db
|
||||
|
||||
msg_info "Generating Security Keys"
|
||||
mkdir -p /opt/geopulse/{backend,keys}
|
||||
mkdir -p /etc/geopulse /var/www/geopulse /var/lib/geopulse/dumps
|
||||
mkdir -p /var/log/geopulse/{backend,nginx}
|
||||
openssl genpkey -algorithm RSA -out /opt/geopulse/keys/jwt-private-key.pem 2>/dev/null
|
||||
openssl rsa -pubout -in /opt/geopulse/keys/jwt-private-key.pem -out /opt/geopulse/keys/jwt-public-key.pem 2>/dev/null
|
||||
openssl rand -base64 32 >/opt/geopulse/keys/ai-encryption-key.txt
|
||||
chmod 640 /opt/geopulse/keys/jwt-private-key.pem /opt/geopulse/keys/jwt-public-key.pem /opt/geopulse/keys/ai-encryption-key.txt
|
||||
chmod 640 /opt/geopulse/keys/ai-encryption-key.txt
|
||||
msg_ok "Generated Security Keys"
|
||||
|
||||
if [[ "$(uname -m)" == "aarch64" ]]; then
|
||||
@@ -62,8 +60,6 @@ GEOPULSE_POSTGRES_PORT=5432
|
||||
GEOPULSE_POSTGRES_DB=${PG_DB_NAME}
|
||||
GEOPULSE_POSTGRES_USERNAME=${PG_DB_USER}
|
||||
GEOPULSE_POSTGRES_PASSWORD=${PG_DB_PASS}
|
||||
GEOPULSE_JWT_PRIVATE_KEY_LOCATION=file:/opt/geopulse/keys/jwt-private-key.pem
|
||||
GEOPULSE_JWT_PUBLIC_KEY_LOCATION=file:/opt/geopulse/keys/jwt-public-key.pem
|
||||
GEOPULSE_AI_ENCRYPTION_KEY_LOCATION=file:/opt/geopulse/keys/ai-encryption-key.txt
|
||||
QUARKUS_LOG_FILE_ENABLE=true
|
||||
QUARKUS_LOG_FILE_PATH=/var/log/geopulse/backend/geopulse.log
|
||||
@@ -128,6 +124,14 @@ server {
|
||||
add_header Cache-Control "public, max-age=31536000";
|
||||
}
|
||||
|
||||
location ~* ^/(?!osm/).*\.mjs$ {
|
||||
types {
|
||||
application/javascript mjs;
|
||||
}
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, max-age=31536000";
|
||||
}
|
||||
|
||||
location ^~ /osm/tiles/ {
|
||||
resolver 8.8.8.8 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
Reference in New Issue
Block a user