bundles/users: add option to enable lingering
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-07-17 11:33:43 +02:00
parent 9fc86a4d9f
commit 6a144cf991
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 62 additions and 5 deletions

View file

@ -1,9 +1,5 @@
from os.path import join, exists
directories = {}
users = {}
groups = {}
files = {
'/etc/bash.bashrc': {
'source': 'bashrc',
@ -76,3 +72,18 @@ for username, attrs in node.metadata['users'].items():
files[home + '/.bashrc'] = {
'delete': True,
}
if attrs.get('enable_linger', False):
linger_test = ''
linger_command = 'enable'
else:
linger_test = '!'
linger_command = 'disable'
actions[f'ensure_linger_state_for_user_{username}'] = {
'command': f'loginctl {linger_command}-linger {username}',
'unless': f'{linger_test} test -f /var/lib/systemd/linger/{username}',
'needs': {
f'user:{username}',
},
}