particle-os-modules/modules/systemd/systemd.sh
fiftydinar 33226b9b73
feat(systemd): Add support for unmasking & masking units (#88)
* feat(systemd): Add support for masking services

* Use unit term in README

* Fix README grammar

* Note about unmasking

* Fix typo in README

* Add unmask & more info about systemctl commands

Address:

https://github.com/ublue-os/bling/pull/88#discussion_r1436877565

https://github.com/ublue-os/bling/pull/88#discussion_r1436917124

* docs: clarify purpose of unmasking

* docs: Fix systemd module README typo

---------

Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
2023-12-31 10:31:49 +00:00

63 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Tell build process to exit if there are any errors.
set -oue pipefail
get_yaml_array ENABLED '.system.enabled[]' "$1"
get_yaml_array DISABLED '.system.disabled[]' "$1"
get_yaml_array UNMASKED '.system.unmasked[]' "$1"
get_yaml_array MASKED '.system.masked[]' "$1"
get_yaml_array USER_ENABLED '.user.enabled[]' "$1"
get_yaml_array USER_DISABLED '.user.disabled[]' "$1"
get_yaml_array USER_UNMASKED '.user.unmasked[]' "$1"
get_yaml_array USER_MASKED '.user.masked[]' "$1"
if [[ ${#ENABLED[@]} -gt 0 ]]; then
for unit in "${ENABLED[@]}"; do
unit=$(printf "$unit")
systemctl -f enable $unit
done
fi
if [[ ${#DISABLED[@]} -gt 0 ]]; then
for unit in "${DISABLED[@]}"; do
unit=$(printf "$unit")
systemctl disable $unit
done
fi
if [[ ${#UNMASKED[@]} -gt 0 ]]; then
for unit in "${UNMASKED[@]}"; do
unit=$(printf "$unit")
systemctl unmask $unit
done
fi
if [[ ${#MASKED[@]} -gt 0 ]]; then
for unit in "${MASKED[@]}"; do
unit=$(printf "$unit")
systemctl mask $unit
done
fi
if [[ ${#USER_ENABLED[@]} -gt 0 ]]; then
for unit in "${USER_ENABLED[@]}"; do
unit=$(printf "$unit")
systemctl --global -f enable $unit
done
fi
if [[ ${#USER_DISABLED[@]} -gt 0 ]]; then
for unit in "${USER_DISABLED[@]}"; do
unit=$(printf "$unit")
systemctl --global disable $unit
done
fi
if [[ ${#USER_UNMASKED[@]} -gt 0 ]]; then
for unit in "${USER_UNMASKED[@]}"; do
unit=$(printf "$unit")
systemctl --global unmask $unit
done
fi
if [[ ${#USER_MASKED[@]} -gt 0 ]]; then
for unit in "${USER_MASKED[@]}"; do
unit=$(printf "$unit")
systemctl --global mask $unit
done
fi