Charakterverwalter (westreiche_website) ergänzen, Website-Nav "Charaktere"

This commit is contained in:
torsten 2026-11-21 04:02:29 +01:00
parent d107f90c93
commit 01dae01c7c
84 changed files with 8915 additions and 17 deletions

View file

@ -0,0 +1,108 @@
#!/usr/bin/env bash
# Westreiche – Charakterverwalter per FTPS auf den Server laden.
#
# Ziel: public_html/<APP_DIRECTORY>/ (APP_DIRECTORY aus credentials.txt).
# Die Zugangsdaten kommen aus ../../credentials.txt (gitignored).
#
# ./tools/deploy_app.sh --dry-run # nur zeigen, was hochgeht
# ./tools/deploy_app.sh # hochladen
set -euo pipefail
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
REPO_ROOT="$(cd "${APP_DIR}/.." && pwd)"
CREDENTIALS="${REPO_ROOT}/credentials.txt"
DRY_RUN=0
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=1
if [[ ! -f "${CREDENTIALS}" ]]; then
echo "credentials.txt fehlt: ${CREDENTIALS}" >&2
exit 1
fi
set -a
# shellcheck disable=SC1090
. "${CREDENTIALS}"
set +a
: "${FTP_URL:?FTP_URL fehlt}" "${FTP_USER:?FTP_USER fehlt}" "${FTP_PASSWORD:?FTP_PASSWORD fehlt}"
APP_DIRECTORY="${APP_DIRECTORY:-westreiche_website}"
TARGET="/public_html/${APP_DIRECTORY}"
curl_ftp() {
curl -s -S --ssl-reqd --user "${FTP_USER}:${FTP_PASSWORD}" "$@"
}
# config.local.php aus den credentials bauen (nicht im Repo ablegen)
CONFIG_TMP="$(mktemp)"
trap 'rm -f "${CONFIG_TMP}"' EXIT
python3 - "${CONFIG_TMP}" <<'PY'
import os, sys
path = sys.argv[1]
def q(key):
return os.environ[key].replace("\\", "\\\\").replace("'", "\\'")
app_dir = os.environ.get("APP_DIRECTORY") or "westreiche_website"
public_url = os.environ.get("APP_PUBLIC_URL") or "https://zauberturm.de"
content = f"""<?php
return [
'db' => [
'host' => '{q('DB_HOST').strip()}',
'port' => {int(os.environ.get('DB_PORT', '3306'))},
'name' => '{q('DB_NAME')}',
'user' => '{q('DB_USER')}',
'password' => '{q('DB_PASSWORD')}',
'charset' => 'utf8mb4',
],
'mail' => [
'host' => '{q('MAIL_HOST').strip()}',
'port' => {int(os.environ.get('MAIL_PORT', '587'))},
'secure' => '{os.environ.get('MAIL_SECURE', 'tls').strip()}',
'user' => '{q('MAIL_USER').strip()}',
'password' => '{q('MAIL_PASSWORD')}',
'from' => '{q('MAIL_FROM').strip()}',
'from_name' => '{q('MAIL_FROM_NAME').strip()}',
'timeout' => 15,
],
'app' => [
'base_path' => '/{app_dir}',
'public_url' => '{public_url}',
'storage_path' => dirname(__DIR__) . '/storage',
'install_token' => '{os.environ.get('INSTALL_TOKEN') or ''}',
'session_idle_seconds' => 30 * 86400,
'session_absolute_seconds' => 90 * 86400,
'remember_seconds' => 90 * 86400,
'login_window_seconds' => 900,
'login_max_per_user' => 5,
'login_max_per_ip' => 15,
],
];
"""
open(path, "w", encoding="utf-8").write(content)
PY
upload() {
local src="$1" dst="$2"
if [[ ${DRY_RUN} -eq 1 ]]; then
echo "PUT ${src#${APP_DIR}/} -> ${dst}"
return
fi
curl_ftp --ftp-create-dirs -T "${src}" "ftp://${FTP_URL}${dst}"
}
echo "Ziel: ftp://${FTP_URL}${TARGET}"
# Verzeichnisse anlegen (FTP braucht MKD je Ebene; --ftp-create-dirs erledigt das)
find "${APP_DIR}" -type f \
! -name 'config.local.php' \
! -name '.DS_Store' \
| sort | while read -r file; do
rel="${file#${APP_DIR}/}"
upload "${file}" "${TARGET}/${rel}"
done
if [[ ${DRY_RUN} -eq 1 ]]; then
echo "PUT app/config.local.php -> ${TARGET}/app/config.local.php"
else
curl_ftp --ftp-create-dirs -T "${CONFIG_TMP}" "ftp://${FTP_URL}${TARGET}/app/config.local.php"
echo "Fertig. Installation: https://…${TARGET}/install.php?token=${INSTALL_TOKEN:-<INSTALL_TOKEN>}"
fi