/usr/lib/imh-ultrastack-common/venv/lib/python3.13/site-packages/ngxutil
NameSizeModeActions
__pycache__/-0755rm
api.py47230644editdlrm
cache.py69380644editdlrm
cli.py107020644editdlrm
info.py149160644editdlrm
logparse.py105370644editdlrm
profile.py17580644editdlrm
report.py146180644editdlrm
sendmail.py13740644editdlrm
util.py28880644editdlrm
vts.py17100644editdlrm
__init__.py4050644editdlrm
Edit: /usr/lib/imh-ultrastack-common/venv/lib/python3.13/site-packages/ngxutil/profile.py (1758B)
# vim: set ts=4 sw=4 expandtab syntax=python: """ ngxutil.profile Profile Management Functions @author J. Hipps """ import os import logging import yaml from yaml import CDumper, CLoader from ngxconf.util import parse_profiles, get_profile logger = logging.getLogger('ngxutil') def set_domain_profile(user, domain, profile): """ Set profile for a user's domain to @profile """ parse_profiles() tprof = get_profile(profile) if tprof is None: logger.error("No profile named '%s' was found", profile) return False domfile = '%s.yml' % (domain.replace('.', '_')) cpath = os.path.join('/home', user, '.imh/nginx', domfile) # Read existing config to pull out SSL options try: with open(cpath) as f: econf = yaml.load(stream=f, Loader=CLoader) logger.debug("Parsed user config at %s", cpath) nconf = { 'ssl_certificate': econf.get('ssl_certificate'), 'ssl_certificate_key': econf.get('ssl_certificate_key'), 'ssl_enabled': econf.get('ssl_enabled'), 'proxy_proto': econf.get('proxy_proto'), } except Exception as e: logger.error("Failed to read existing config file: %s", str(e)) nconf = {} # merge in SSL options tprof.update(nconf) # Write updated config try: with open(cpath, 'w') as f: yaml.dump(tprof, stream=f, Dumper=CDumper, default_flow_style=False) logger.info("Wrote updated config file for %s:%s to %s", user, domain, cpath) except Exception as e: logger.error("Failed to write config file [%s]: %s", cpath, str(e)) return False return True