def install_service(): """Install systemd service configuration""" _check_root() hfoslog("Installing systemd service", emitter="MANAGE") launcher = os.path.realpath(__file__).replace('manage', 'launcher') executable = sys.executable + " " + launcher executable += " --dolog --logfile /var/log/hfos.log" executable += " --logfileverbosity 30 -q" definitions = { 'executable': executable } write_template_file(os.path.join('dev/templates', service_template), '/etc/systemd/system/hfos.service', definitions) Popen([ 'systemctl', 'enable', 'hfos.service' ]) hfoslog("Done: Install Service", emitter="MANAGE")
def install_nginx(hostname=None): """Install nginx configuration""" _check_root() hfoslog("Installing nginx configuration", emitter="MANAGE") global key_file global cert_file global combined_file if hostname is None: try: config = _get_system_configuration() hostname = config.hostname except Exception as e: hfoslog('Exception:', e, type(e), exc=True, lvl=error) hfoslog("""Could not determine public fully qualified hostname! Check systemconfig (see db view and db modify commands) or specify manually with --hostname host.domain.tld Using 'localhost' for now""", lvl=warn) hostname = 'localhost' definitions = { 'server_public_name': hostname, 'ssl_certificate': cert_file, 'ssl_key': key_file, 'host_url': 'http://127.0.0.1:8055/' } configuration_file = '/etc/nginx/sites-available/hfos.conf' configuration_link = '/etc/nginx/sites-enabled/hfos.conf' hfoslog('Writing nginx HFOS site definition') write_template_file(os.path.join('dev/templates', nginx_configuration), configuration_file, definitions) hfoslog('Enabling nginx HFOS site') if not os.path.exists(configuration_link): os.symlink(configuration_file, configuration_link) hfoslog('Restarting nginx service') Popen([ 'systemctl', 'restart', 'nginx.service' ]) hfoslog("Done: Install nginx configuration", emitter="MANAGE")
def _construct_module(info, target): """Build a module from templates and user supplied information""" for path in paths: real_path = os.path.abspath(os.path.join(target, path.format(**info))) hfoslog("Making directory '%s'" % real_path, emitter='MANAGE') os.makedirs(real_path) # pprint(info) for item in templates.values(): source = os.path.join('dev/templates', item[0]) filename = os.path.abspath( os.path.join(target, item[1].format(**info))) hfoslog("Creating file from template '%s'" % filename, emitter='MANAGE') write_template_file(source, filename, info)