systemd mount defaults

This commit is contained in:
cronekorkn 2023-03-31 16:56:45 +02:00
parent fc115345a0
commit 233760d7a8
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
3 changed files with 13 additions and 25 deletions

View file

@ -15,16 +15,14 @@ defaults = {
def units(metadata): def units(metadata):
units = {} units = {}
services = {} services = {}
for mountpoint, conf in metadata.get('systemd-mount').items(): for mountpoint, conf in metadata.get('systemd-mount').items():
formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount' formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount'
units[formatted_name] = { units[formatted_name] = {
'Unit': { 'Unit': {
'Description': f"Mount {conf['source']} -> {mountpoint}", 'Description': f"Mount {conf['source']} -> {mountpoint}",
'DefaultDependencies': 'no', 'DefaultDependencies': 'no',
'Conflicts': 'umount.target',
'Before': 'umount.target',
}, },
'Mount': { 'Mount': {
'What': conf['source'], 'What': conf['source'],
@ -32,16 +30,11 @@ def units(metadata):
'Type': 'fuse.bindfs', 'Type': 'fuse.bindfs',
'Options': f"nonempty", 'Options': f"nonempty",
}, },
'Install': {
'WantedBy': {
'local-fs.target',
},
},
} }
if conf.get('user'): if conf.get('user'):
units[formatted_name]['Mount']['Options'] += f",force-user={conf.get('user')}" units[formatted_name]['Mount']['Options'] += f",force-user={conf.get('user')}"
services[formatted_name] = {} services[formatted_name] = {}
return { return {

View file

@ -3,7 +3,7 @@
## show unit paths ## show unit paths
``` ```
systemctl --no-pager --property=UnitPath show | tr ' ' '\n' systemctl --no-pager --property=UnitPath show --value | tr ' ' '\n'
``` ```
## metadata ## metadata

View file

@ -25,19 +25,14 @@ def units(metadata):
type = name.split('.')[-1] type = name.split('.')[-1]
if not config.get('Install/WantedBy'): if type == 'service':
if type == 'service': units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'multi-user.target'})
units[name] = { elif type == 'timer':
'Install': { units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'timers.target'})
'WantedBy': {'multi-user.target'}, elif type == 'mount':
} units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'local-fs.target'})
} units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Conflicts', {'umount.target'})
elif type == 'timer': units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Before', {'umount.target'})
units[name] = {
'Install': {
'WantedBy': {'timers.target'},
}
}
return { return {
'systemd': { 'systemd': {