particle-os-modules/modules/systemd/systemd.sh
Nick Saika 17bacbe3da
fix: Fix flag ordering in set calls in scripts (#99)
The README for scripts has an incorrect use of the `set`. Where it says
to use:

	set -oue pipefail

it should be:

	set -euo pipefail

since `pipefail` is an option consumed by `set -o`.

More information: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
2024-01-16 06:12:08 +00:00

63 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Tell build process to exit if there are any errors.
set -euo 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