[verified] Publish ReelBox source under GPLv3
This commit is contained in:
commit
db2b505ca3
445 files changed
+105274
No files matched your search
@@ -0,0 +1,23 @@
|
||||
"""Install API routing on the existing Iran ReelBox HTTPS server."""
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
config = Path('/etc/reelbox/nginx.conf')
|
||||
original = config.read_text()
|
||||
include = ' include /etc/reelbox/api-locations.conf;\n'
|
||||
if include not in original:
|
||||
anchor = ' root /var/www/reelbox/current;\n'
|
||||
if original.count(anchor) != 1:
|
||||
raise RuntimeError('Unexpected site configuration; refusing to alter it')
|
||||
backup = config.with_name('nginx.conf.' + datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ') + '.backup')
|
||||
shutil.copy2(config, backup)
|
||||
config.write_text(original.replace(anchor, include + anchor))
|
||||
try:
|
||||
subprocess.run(['/usr/sbin/nginx', '-t', '-c', str(config)], check=True)
|
||||
except Exception:
|
||||
config.write_text(original)
|
||||
raise
|
||||
subprocess.run(['systemctl', 'reload', 'reelbox-web'], check=True)
|
||||
print('ReelBox metadata API routes enabled; website root and existing listeners unchanged')
|
||||
Reference in new issue
Block a user