diff --git a/chutney.service b/chutney.service index dd6d6ae..b854982 100644 --- a/chutney.service +++ b/chutney.service @@ -8,6 +8,7 @@ WorkingDirectory=$workingDirectory ExecStart=$execStart Restart=on-failure SyslogIdentifier=chutney +User=$user [Install] WantedBy=multi-user.target diff --git a/install b/install index cb9995a..14ecce7 100755 --- a/install +++ b/install @@ -5,6 +5,7 @@ import sys from string import Template from subprocess import check_call +from subprocess import check_output EXEC = 'chutney.py' SERVICE = 'chutney.service' @@ -15,13 +16,15 @@ SERVICE_TEMPLATE = os.path.join(CURRENT_DIR, SERVICE) SERVICE_FILE = os.path.join(SYSTEM_DIR, SERVICE) PYTHON = sys.executable EXEC_START = f'{PYTHON} {EXEC}' +USER = check_output(['logname']).decode('utf-8').strip() with open(SERVICE_TEMPLATE) as f: serviceTemplate = Template(f.read()) serviceFile = serviceTemplate.substitute( workingDirectory=CURRENT_DIR, - execStart=EXEC_START + execStart=EXEC_START, + user=USER ) with open(SERVICE_FILE, 'w') as f: