"""Publish the Company CP outer shell from a verified release, without changing DNS or TLS.""" from pathlib import Path import os import pwd import sys source = Path(__file__).resolve().parents[1] / 'ops' target = Path('/var/www/dunerealms-corp') files = {'index.html': 'company-center-index.html', 'company-shell.js': 'company-cp-shell.js', 'company-shell.css': 'company-shell.css'} if '--apply' not in sys.argv: print('Plan: publish Company CP to its dedicated host directory') sys.exit(0) if os.geteuid() != 0: raise RuntimeError('Deployment operator required') owner = pwd.getpwnam('dunerealms') target.mkdir(parents=True, exist_ok=True) os.chown(target, owner.pw_uid, owner.pw_gid) for name, origin in files.items(): path = target / name temporary = path.with_name(name + '.company-new') temporary.write_bytes((source / origin).read_bytes()) temporary.chmod(0o644) os.chown(temporary, owner.pw_uid, owner.pw_gid) os.replace(temporary, path) print('Published Company CP outer shell')