feat(tenant-management): add school configuration management to tenant script
This commit is contained in:
@@ -49,6 +49,15 @@ Bearbeite `config.json`:
|
||||
|
||||
Falls nicht konfiguriert, werden Platzhalter verwendet.
|
||||
|
||||
Alternativ können Sie die Schulinformationen tenant-spezifisch mit dem Manage-Skript setzen:
|
||||
|
||||
```bash
|
||||
# Beispiel: Schulinformationen für Tenant 'school_a' setzen
|
||||
./manage-tenant.sh school school_a name="Grundschule Albert-Schweitzer-Straße" address="Albert-Schweitzer-Straße 1" postal_code=12345 city="Musterstadt" school_number=042123 it_admin="Max Mustermann"
|
||||
```
|
||||
|
||||
Hinweis: `manage-tenant.sh school` schreibt die Daten unter `tenants.<tenant_id>.school` in `config.json` und löst bei aktiver App-Container-Instanz einen Neustart aus, damit die Änderungen wirksam werden.
|
||||
|
||||
### Schritt 2: System starten
|
||||
|
||||
```bash
|
||||
|
||||
@@ -17,8 +17,11 @@ from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
import settings as cfg
|
||||
|
||||
|
||||
__version__ = cfg.APP_VERSION
|
||||
|
||||
class DIN5008AuditPDF:
|
||||
"""
|
||||
Professional PDF generator for audit reports compliant with:
|
||||
@@ -137,7 +140,7 @@ class DIN5008AuditPDF:
|
||||
Erstellungsdatum: {created_date}<br/>
|
||||
Uhrzeit: {created_time}<br/>
|
||||
Verantwortliche Person: {responsible_person}<br/>
|
||||
System: Invario v2.6.5
|
||||
System: Invario v{__version__}
|
||||
"""
|
||||
|
||||
story.append(Paragraph(info_text, info_style))
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"dbg": false,
|
||||
"key": "InventarsystemSecureKey2026XYZ789abcdef012",
|
||||
"ver": "0.6.44",
|
||||
"ver": "0.7.20",
|
||||
"host": "0.0.0.0",
|
||||
"port": 8000,
|
||||
"mongodb": {
|
||||
|
||||
@@ -21,6 +21,7 @@ show_help() {
|
||||
echo " restart-all Restart all application containers (zero-downtime reload)"
|
||||
echo " list List active tenants"
|
||||
echo " module <tenant_id> <module>=<on|off>... Enable/disable modules for a tenant"
|
||||
echo " school <tenant_id> [key]=[value]... Set school configuration for tenant (name,address,postal_code,city,school_number,it_admin)"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
@@ -565,6 +566,62 @@ PY
|
||||
fi
|
||||
;;
|
||||
|
||||
school)
|
||||
# Usage: manage-tenant.sh school <tenant_id> key=value [...]
|
||||
if [ -z "$TENANT_ID" ] || [ -z "${3:-}" ]; then
|
||||
echo "Error: Usage: manage-tenant.sh school <tenant_id> key=value [...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pass all remaining args to python to update tenants[tenant_id]['school']
|
||||
shift 2
|
||||
|
||||
if python3 - "$CONFIG_FILE" "$TENANT_ID" "$@" <<'PY'
|
||||
import json, sys, os
|
||||
path = sys.argv[1]
|
||||
tenant_id = sys.argv[2]
|
||||
kv_args = sys.argv[3:]
|
||||
|
||||
if not os.path.isfile(path):
|
||||
print(f"Error: config file not found: {path}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
cfg = json.load(f)
|
||||
|
||||
tenants = cfg.setdefault('tenants', {})
|
||||
tenant_cfg = tenants.setdefault(tenant_id, {})
|
||||
school_cfg = tenant_cfg.setdefault('school', {})
|
||||
|
||||
for arg in kv_args:
|
||||
if '=' not in arg:
|
||||
print(f"Warning: Ignoring invalid argument '{arg}'. Expected key=value.", file=sys.stderr)
|
||||
continue
|
||||
key, val = arg.split('=', 1)
|
||||
key = key.strip()
|
||||
val = val.strip()
|
||||
# try to coerce numeric values
|
||||
if val.isdigit():
|
||||
val_parsed = int(val)
|
||||
else:
|
||||
val_parsed = val
|
||||
school_cfg[key] = val_parsed
|
||||
print(f"Set school.{key} = {val_parsed} for tenant {tenant_id}")
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
json.dump(cfg, f, indent=4, ensure_ascii=False)
|
||||
PY
|
||||
then
|
||||
echo "School configuration updated successfully in config.json for tenant '$TENANT_ID'."
|
||||
if [ -n "$(docker ps -qf 'name=app' | head -n 1)" ]; then
|
||||
restart_app_container
|
||||
fi
|
||||
else
|
||||
echo "Failed to update school configuration for tenant '$TENANT_ID'."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown command: $COMMAND"
|
||||
show_help
|
||||
|
||||
Reference in New Issue
Block a user