config into config files
This commit is contained in:
parent
c1bc20d876
commit
9b2c79b039
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,5 +10,6 @@
|
|||||||
/search.db
|
/search.db
|
||||||
/access_log.db
|
/access_log.db
|
||||||
/access_log.db.bak
|
/access_log.db.bak
|
||||||
/folder_config.json
|
/folder_permission_config.json
|
||||||
|
/folder_mount_config.json
|
||||||
/.env
|
/.env
|
||||||
2
auth.py
2
auth.py
@ -14,7 +14,7 @@ def require_secret(f):
|
|||||||
def decorated_function(*args, **kwargs):
|
def decorated_function(*args, **kwargs):
|
||||||
global folder_config
|
global folder_config
|
||||||
if not folder_config:
|
if not folder_config:
|
||||||
with open('folder_config.json') as file:
|
with open('folder_permission_config.json') as file:
|
||||||
folder_config = json.load(file)
|
folder_config = json.load(file)
|
||||||
|
|
||||||
def is_valid(config_item, provided_secret):
|
def is_valid(config_item, provided_secret):
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"secret" : "dev_key_f83745ft0g5rg3",
|
|
||||||
"validity" : "31.12.2030",
|
|
||||||
"folders": [
|
|
||||||
{
|
|
||||||
"foldername": "My Folder",
|
|
||||||
"folderpath": "\\\\path\\if\\using\\windows"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,50 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Configuration Section
|
# Configuration Section (Loaded from config.json)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Server 1 Configuration
|
|
||||||
SERVER1_SSH_USER="root"
|
|
||||||
SERVER1_SSH_SERVER="bethaus-speyer.de"
|
|
||||||
SERVER1_SSH_SERVER_PORT=1122 # Remote SSH server port for Server 1
|
|
||||||
SERVER1_REMOTE_NFS_PORT=2049 # Remote NFS server port (usually 2049)
|
|
||||||
SERVER1_LOCAL_PORT_BASE=2022 # Base local port for SSH tunnel (will add index offset)
|
|
||||||
|
|
||||||
# Define multiple mount configurations for Server 1
|
CONFIG_FILE="folder_mount_config.json"
|
||||||
# Each index corresponds to a mount point and NFS share.
|
|
||||||
SERVER1_MOUNT_POINTS=(
|
|
||||||
"/mnt/Gottesdienste Speyer"
|
|
||||||
"/mnt/Besondere Gottesdienste"
|
|
||||||
"/mnt/Liedersammlung"
|
|
||||||
"/mnt/Hochzeiten Speyer"
|
|
||||||
"/mnt/app_share"
|
|
||||||
)
|
|
||||||
SERVER1_NFS_SHARES=(
|
|
||||||
"/volume1/Aufnahme-stereo/010 Gottesdienste ARCHIV"
|
|
||||||
"/volume1/Aufnahme-stereo/013 Besondere Gottesdienste"
|
|
||||||
"/volume1/Aufnahme-stereo/014 Liedersammlung"
|
|
||||||
"/volume1/Aufnahme-stereo/021 Hochzeiten in Speyer"
|
|
||||||
"/volume1/app_share"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Server 2 Configuration
|
# Ensure jq is installed before proceeding.
|
||||||
SERVER2_SSH_USER="root"
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
SERVER2_SSH_SERVER="bethaus-schwegenheim.de"
|
echo "[ERROR] 'jq' is not installed. Please install jq and try again."
|
||||||
SERVER2_SSH_SERVER_PORT=1122 # Remote SSH server port for Server 2
|
exit 1
|
||||||
SERVER2_REMOTE_NFS_PORT=2049 # Remote NFS server port
|
fi
|
||||||
SERVER2_LOCAL_PORT_BASE=3022 # Base local port for SSH tunnel (will add index offset)
|
|
||||||
|
|
||||||
# Define multiple mount configurations for Server 2
|
# Load Server 1 configuration
|
||||||
SERVER2_MOUNT_POINTS=(
|
SERVER1_SSH_USER=$(jq -r '.SERVER1.SSH_USER' "$CONFIG_FILE")
|
||||||
"/mnt/Gottesdienste Schwegenheim"
|
SERVER1_SSH_SERVER=$(jq -r '.SERVER1.SSH_SERVER' "$CONFIG_FILE")
|
||||||
"/mnt/Hochzeiten Schwegenheim"
|
SERVER1_SSH_SERVER_PORT=$(jq -r '.SERVER1.SSH_SERVER_PORT' "$CONFIG_FILE")
|
||||||
)
|
SERVER1_REMOTE_NFS_PORT=$(jq -r '.SERVER1.REMOTE_NFS_PORT' "$CONFIG_FILE")
|
||||||
SERVER2_NFS_SHARES=(
|
SERVER1_LOCAL_PORT_BASE=$(jq -r '.SERVER1.LOCAL_PORT_BASE' "$CONFIG_FILE")
|
||||||
"/volume1/Aufnahme-stereo/010 Gottesdienste ARCHIV"
|
readarray -t SERVER1_MOUNT_POINTS < <(jq -r '.SERVER1.MOUNT_POINTS[]' "$CONFIG_FILE")
|
||||||
"/volume1/Aufnahme-stereo/020 Hochzeiten"
|
readarray -t SERVER1_NFS_SHARES < <(jq -r '.SERVER1.NFS_SHARES[]' "$CONFIG_FILE")
|
||||||
)
|
|
||||||
|
|
||||||
# List of server identifiers (must match the prefix of configuration variables)
|
# Load Server 2 configuration
|
||||||
|
SERVER2_SSH_USER=$(jq -r '.SERVER2.SSH_USER' "$CONFIG_FILE")
|
||||||
|
SERVER2_SSH_SERVER=$(jq -r '.SERVER2.SSH_SERVER' "$CONFIG_FILE")
|
||||||
|
SERVER2_SSH_SERVER_PORT=$(jq -r '.SERVER2.SSH_SERVER_PORT' "$CONFIG_FILE")
|
||||||
|
SERVER2_REMOTE_NFS_PORT=$(jq -r '.SERVER2.REMOTE_NFS_PORT' "$CONFIG_FILE")
|
||||||
|
SERVER2_LOCAL_PORT_BASE=$(jq -r '.SERVER2.LOCAL_PORT_BASE' "$CONFIG_FILE")
|
||||||
|
readarray -t SERVER2_MOUNT_POINTS < <(jq -r '.SERVER2.MOUNT_POINTS[]' "$CONFIG_FILE")
|
||||||
|
readarray -t SERVER2_NFS_SHARES < <(jq -r '.SERVER2.NFS_SHARES[]' "$CONFIG_FILE")
|
||||||
|
|
||||||
|
# Define list of server identifiers (must match JSON keys)
|
||||||
SERVERS=("SERVER1" "SERVER2")
|
SERVERS=("SERVER1" "SERVER2")
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
Loading…
x
Reference in New Issue
Block a user