Update service user

This commit is contained in:
Mike Cifelli 2022-12-23 12:37:27 -05:00
parent 4e642ca4fd
commit bce19458ee
2 changed files with 5 additions and 1 deletions

View File

@ -8,6 +8,7 @@ WorkingDirectory=$workingDirectory
ExecStart=$execStart
Restart=on-failure
SyslogIdentifier=chutney
User=$user
[Install]
WantedBy=multi-user.target

View File

@ -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: