Update service user
This commit is contained in:
parent
4e642ca4fd
commit
bce19458ee
|
@ -8,6 +8,7 @@ WorkingDirectory=$workingDirectory
|
||||||
ExecStart=$execStart
|
ExecStart=$execStart
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
SyslogIdentifier=chutney
|
SyslogIdentifier=chutney
|
||||||
|
User=$user
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
5
install
5
install
|
@ -5,6 +5,7 @@ import sys
|
||||||
|
|
||||||
from string import Template
|
from string import Template
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
from subprocess import check_output
|
||||||
|
|
||||||
EXEC = 'chutney.py'
|
EXEC = 'chutney.py'
|
||||||
SERVICE = 'chutney.service'
|
SERVICE = 'chutney.service'
|
||||||
|
@ -15,13 +16,15 @@ SERVICE_TEMPLATE = os.path.join(CURRENT_DIR, SERVICE)
|
||||||
SERVICE_FILE = os.path.join(SYSTEM_DIR, SERVICE)
|
SERVICE_FILE = os.path.join(SYSTEM_DIR, SERVICE)
|
||||||
PYTHON = sys.executable
|
PYTHON = sys.executable
|
||||||
EXEC_START = f'{PYTHON} {EXEC}'
|
EXEC_START = f'{PYTHON} {EXEC}'
|
||||||
|
USER = check_output(['logname']).decode('utf-8').strip()
|
||||||
|
|
||||||
with open(SERVICE_TEMPLATE) as f:
|
with open(SERVICE_TEMPLATE) as f:
|
||||||
serviceTemplate = Template(f.read())
|
serviceTemplate = Template(f.read())
|
||||||
|
|
||||||
serviceFile = serviceTemplate.substitute(
|
serviceFile = serviceTemplate.substitute(
|
||||||
workingDirectory=CURRENT_DIR,
|
workingDirectory=CURRENT_DIR,
|
||||||
execStart=EXEC_START
|
execStart=EXEC_START,
|
||||||
|
user=USER
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(SERVICE_FILE, 'w') as f:
|
with open(SERVICE_FILE, 'w') as f:
|
||||||
|
|
Loading…
Reference in New Issue