nginx database initial fix test

This commit is contained in:
2026-03-04 13:08:36 +01:00
parent 43b8cfb296
commit 8f8ed0084e
21 changed files with 110 additions and 1182 deletions

View File

@@ -36,6 +36,58 @@ replace_string_recursive() {
# example use
# replace_string_recursive "/path/to/directory" "oldstring" "newstring"
# sqlite db replace function
replace_in_sqlite_db() {
local DB_PATH="$1"
local OLD_STRING="$2"
local NEW_STRING="$3"
# Check if the database file exists
if [ ! -f "$DB_PATH" ]; then
echo "Error: Database file '$DB_PATH' does not exist."
return 1
fi
echo "Starting replacement of '$OLD_STRING' with '$NEW_STRING' in '$DB_PATH'..."
# Get a list of all tables in the database
local TABLES
TABLES=$(sqlite3 "$DB_PATH" ".tables")
# Loop through each table
for TABLE in $TABLES; do
echo "Processing table: $TABLE"
# Get a list of all columns in the table
local COLUMNS
COLUMNS=$(sqlite3 "$DB_PATH" "PRAGMA table_info($TABLE);" | awk -F'|' '{print $2}' | grep -v '^$')
# Loop through each column
for COLUMN in $COLUMNS; do
# Check if the column is a text type (simplistic check)
local COLUMN_TYPE
COLUMN_TYPE=$(sqlite3 "$DB_PATH" "PRAGMA table_info($TABLE);" | awk -F'|' -v col="$COLUMN" '$2 == col {print $3}')
# Only proceed if the column type contains 'TEXT' (case-insensitive)
if [[ "$COLUMN_TYPE" =~ [Tt][Ee][Xx][Tt] ]]; then
echo " Updating column: $COLUMN (type: $COLUMN_TYPE)"
# Perform the replacement
sqlite3 "$DB_PATH" "
UPDATE $TABLE
SET $COLUMN = replace($COLUMN, '$OLD_STRING', '$NEW_STRING')
WHERE $COLUMN LIKE '%$OLD_STRING%';
"
fi
done
done
echo "Replacement completed for all text-type columns in '$DB_PATH'."
}
#example usage: replace_in_sqlite_db "database.sqlite" "Europe/Amsterdam" "UTC"
# what this script needs to do:

58
prepdb.sh Normal file
View File

@@ -0,0 +1,58 @@
# sqlite db replace function
replace_in_sqlite_db() {
local DB_PATH="$1"
local OLD_STRING="$2"
local NEW_STRING="$3"
# Check if the database file exists
if [ ! -f "$DB_PATH" ]; then
echo "Error: Database file '$DB_PATH' does not exist."
return 1
fi
echo "Starting replacement of '$OLD_STRING' with '$NEW_STRING' in '$DB_PATH'..."
# Get a list of all tables in the database
local TABLES
TABLES=$(sqlite3 "$DB_PATH" ".tables")
# Loop through each table
for TABLE in $TABLES; do
echo "Processing table: $TABLE"
# Get a list of all columns in the table
local COLUMNS
COLUMNS=$(sqlite3 "$DB_PATH" "PRAGMA table_info($TABLE);" | awk -F'|' '{print $2}' | grep -v '^$')
# Loop through each column
for COLUMN in $COLUMNS; do
# Check if the column is a text type (simplistic check)
local COLUMN_TYPE
COLUMN_TYPE=$(sqlite3 "$DB_PATH" "PRAGMA table_info($TABLE);" | awk -F'|' -v col="$COLUMN" '$2 == col {print $3}')
# Only proceed if the column type contains 'TEXT' (case-insensitive)
if [[ "$COLUMN_TYPE" =~ [Tt][Ee][Xx][Tt] ]]; then
echo " Updating column: $COLUMN (type: $COLUMN_TYPE)"
# Perform the replacement
sqlite3 "$DB_PATH" "
UPDATE $TABLE
SET $COLUMN = replace($COLUMN, '$OLD_STRING', '$NEW_STRING')
WHERE $COLUMN LIKE '%$OLD_STRING%';
"
fi
done
done
echo "Replacement completed for all text-type columns in '$DB_PATH'."
}
#set script directory
scriptdir="$(dirname "$(realpath "$0")")"
#example usage: replace_in_sqlite_db "database.sqlite" "Europe/Amsterdam" "UTC"
replace_in_sqlite_db "$scriptdir/stacks/npm/data/database.sqlite" "sdgserver.online" "?domain?"
replace_in_sqlite_db "$scriptdir/stacks/npm/data/database.sqlite" "192.168.2.132" "?localip?"
replace_in_sqlite_db "$scriptdir/stacks/npm/data/database.sqlite" "z5fGWz2i0q" "?adminpass?"
replace_in_sqlite_db "$scriptdir/stacks/npm/data/database.sqlite" "0.0.0.0/0" "?localip?"

Binary file not shown.

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# docker.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "?localip?";
set $port 5001;
listen 80;
listen [::]:80;
server_name docker.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-1_access.log proxy;
error_log /data/logs/proxy-host-1_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,59 +0,0 @@
# ------------------------------------------------------------
# proxy.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "?localip?";
set $port 81;
listen 80;
listen [::]:80;
server_name proxy.?domain?;
http2 off;
access_log /data/logs/proxy-host-10_access.log proxy;
error_log /data/logs/proxy-host-10_error.log warn;
location / {
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# office.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "documentserver";
set $port 80;
listen 80;
listen [::]:80;
server_name office.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-11_access.log proxy;
error_log /data/logs/proxy-host-11_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# cloud.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "owncloud_server";
set $port 8080;
listen 80;
listen [::]:80;
server_name cloud.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-12_access.log proxy;
error_log /data/logs/proxy-host-12_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# www.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "site";
set $port 80;
listen 80;
listen [::]:80;
server_name www.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-13_access.log proxy;
error_log /data/logs/proxy-host-13_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# vault.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "vaultwarden";
set $port 80;
listen 80;
listen [::]:80;
server_name vault.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-14_access.log proxy;
error_log /data/logs/proxy-host-14_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# vpn.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "wireguard";
set $port 51821;
listen 80;
listen [::]:80;
server_name vpn.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-15_access.log proxy;
error_log /data/logs/proxy-host-15_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# mail.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme https;
set $server "?localip?";
set $port 1443;
listen 80;
listen [::]:80;
server_name mail.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-16_access.log proxy;
error_log /data/logs/proxy-host-16_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,59 +0,0 @@
# ------------------------------------------------------------
# dozzle.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "dozzle";
set $port 8080;
listen 80;
listen [::]:80;
server_name dozzle.?domain?;
http2 off;
access_log /data/logs/proxy-host-17_access.log proxy;
error_log /data/logs/proxy-host-17_error.log warn;
location / {
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,59 +0,0 @@
# ------------------------------------------------------------
# dns.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "pihole";
set $port 80;
listen 80;
listen [::]:80;
server_name dns.?domain?;
http2 off;
access_log /data/logs/proxy-host-18_access.log proxy;
error_log /data/logs/proxy-host-18_error.log warn;
location / {
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# docs.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "bookstack";
set $port 80;
listen 80;
listen [::]:80;
server_name docs.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-2_access.log proxy;
error_log /data/logs/proxy-host-2_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# browser.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "browser";
set $port 80;
listen 80;
listen [::]:80;
server_name browser.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-3_access.log proxy;
error_log /data/logs/proxy-host-3_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# convert.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "convertx";
set $port 3000;
listen 80;
listen [::]:80;
server_name convert.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-4_access.log proxy;
error_log /data/logs/proxy-host-4_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# dash.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "dashboard";
set $port 80;
listen 80;
listen [::]:80;
server_name dash.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-5_access.log proxy;
error_log /data/logs/proxy-host-5_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# download.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "192.168.2.132";
set $port 3000;
listen 80;
listen [::]:80;
server_name download.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-6_access.log proxy;
error_log /data/logs/proxy-host-6_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# tools.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "it-tools";
set $port 80;
listen 80;
listen [::]:80;
server_name tools.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-7_access.log proxy;
error_log /data/logs/proxy-host-7_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# video.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "jellyfin";
set $port 8096;
listen 80;
listen [::]:80;
server_name video.sdgserver.online;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-8_access.log proxy;
error_log /data/logs/proxy-host-8_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}

View File

@@ -1,67 +0,0 @@
# ------------------------------------------------------------
# status.sdgserver.online
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "uptime-kuma";
set $port 3001;
listen 80;
listen [::]:80;
server_name status.?domain?;
http2 off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
access_log /data/logs/proxy-host-9_access.log proxy;
error_log /data/logs/proxy-host-9_error.log warn;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}