Show warning if linger is not enabled

This commit is contained in:
Mike Cifelli 2024-04-04 10:32:05 -04:00
parent 0b21da8145
commit 5eb64f5c38
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
1 changed files with 4 additions and 0 deletions

View File

@ -17,6 +17,7 @@ SERVICE_FILE = os.path.join(os.path.expanduser(SYSTEM_DIR), SERVICE)
PYTHON = sys.executable
EXEC_START = f'{PYTHON} {EXEC}'
USER = check_output(['logname']).decode('utf-8').strip()
LINGER = check_output(['loginctl', 'show-user', USER, '--property=Linger']).decode('utf-8').strip()
with open(SERVICE_TEMPLATE) as f:
serviceTemplate = Template(f.read())
@ -35,3 +36,6 @@ check_call(['systemctl', '--user', 'daemon-reload'])
check_call(['systemctl', '--user', 'enable', '--no-pager', SERVICE])
check_call(['systemctl', '--user', 'restart', '--no-pager', SERVICE])
check_call(['systemctl', '--user', 'status', '--no-pager', SERVICE])
if LINGER != 'Linger=yes':
print(f'\n>>> Please run `sudo loginctl enable-linger {USER}` to allow this service to run without being logged in.')