From 233760d7a8f6f287cccc6b993172ecc591ec316d Mon Sep 17 00:00:00 2001 From: cronekorkn Date: Fri, 31 Mar 2023 16:56:45 +0200 Subject: [PATCH] systemd mount defaults --- bundles/systemd-mount/metadata.py | 15 ++++----------- bundles/systemd/README.md | 2 +- bundles/systemd/metadata.py | 21 ++++++++------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/bundles/systemd-mount/metadata.py b/bundles/systemd-mount/metadata.py index cfa0224..55667e0 100644 --- a/bundles/systemd-mount/metadata.py +++ b/bundles/systemd-mount/metadata.py @@ -15,16 +15,14 @@ defaults = { def units(metadata): units = {} services = {} - + for mountpoint, conf in metadata.get('systemd-mount').items(): formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount' - + units[formatted_name] = { 'Unit': { 'Description': f"Mount {conf['source']} -> {mountpoint}", 'DefaultDependencies': 'no', - 'Conflicts': 'umount.target', - 'Before': 'umount.target', }, 'Mount': { 'What': conf['source'], @@ -32,16 +30,11 @@ def units(metadata): 'Type': 'fuse.bindfs', 'Options': f"nonempty", }, - 'Install': { - 'WantedBy': { - 'local-fs.target', - }, - }, } - + if conf.get('user'): units[formatted_name]['Mount']['Options'] += f",force-user={conf.get('user')}" - + services[formatted_name] = {} return { diff --git a/bundles/systemd/README.md b/bundles/systemd/README.md index b7e9cdd..f038708 100644 --- a/bundles/systemd/README.md +++ b/bundles/systemd/README.md @@ -3,7 +3,7 @@ ## show unit paths ``` -systemctl --no-pager --property=UnitPath show | tr ' ' '\n' +systemctl --no-pager --property=UnitPath show --value | tr ' ' '\n' ``` ## metadata diff --git a/bundles/systemd/metadata.py b/bundles/systemd/metadata.py index 364dc32..74c41a5 100644 --- a/bundles/systemd/metadata.py +++ b/bundles/systemd/metadata.py @@ -25,19 +25,14 @@ def units(metadata): type = name.split('.')[-1] - if not config.get('Install/WantedBy'): - if type == 'service': - units[name] = { - 'Install': { - 'WantedBy': {'multi-user.target'}, - } - } - elif type == 'timer': - units[name] = { - 'Install': { - 'WantedBy': {'timers.target'}, - } - } + if type == 'service': + units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'multi-user.target'}) + elif type == 'timer': + units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'timers.target'}) + elif type == 'mount': + units.setdefault(name, {}).setdefault('Install', {}).setdefault('WantedBy', {'local-fs.target'}) + units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Conflicts', {'umount.target'}) + units.setdefault(name, {}).setdefault('Unit', {}).setdefault('Before', {'umount.target'}) return { 'systemd': {