Skip to content
Snippets Groups Projects
Verified Commit ec0daa54 authored by Clayton Craft's avatar Clayton Craft :speech_balloon:
Browse files

fixup! systemd/postmarketos-base-systemd: run systemctl on preset changes for...

fixup! systemd/postmarketos-base-systemd: run systemctl on preset changes for already installed units (MR 6120)
parent 578700cd
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ user_preset_path="/usr/lib/systemd/user-preset/90-base.preset"
# $1: path to file (without .old)
remove_old() {
rm "$1.old" || true
rm "$1.old" 2>/dev/null || true
}
# https://www.freedesktop.org/software/systemd/man/latest/systemd.preset.html
......@@ -31,6 +31,11 @@ remove_old() {
# $1: path to preset
units_affected_by_preset() {
# https://stackoverflow.com/questions/4198138/printing-everything-except-the-first-field-with-awk
if [ ! -f "$1" ]; then
# If the file doesn't exist, then there's no policy
echo ""
return
fi
# "enable unit.service abc def" becomes "unit.service abc def"
cat "$1" |
busybox awk '$1 == "enable" || $1 == "disable" || $1 == "ignore"' |
......@@ -58,6 +63,12 @@ get_policy_for_unit() {
# FIXME: better shell escaping
local escaped="$(echo "$2" | sed 's/\*/\\\*/')"
if [ ! -f "$1" ]; then
# If the file doesn't exist, then there's no policy
echo ""
return
fi
cat $1 |
grep "$escaped"'$' |
awk '$1 == "enable" || $1 == "disable" || $1 == "ignore" {print $1}'
......@@ -94,7 +105,11 @@ check_and_apply_presets() {
if echo "$entry" | grep -q '*'; then
echo " wildcards are not supported yet, skipping"
else
[ -f "/usr/lib/systemd/$type/$entry" ] && systemd_service_post_install "$type" "$entry"
if [ -f "/usr/lib/systemd/$type/$entry" ]; then
systemd_service_post_install "$type" "$entry"
else
echo " no unit file found, skipping"
fi
fi
fi
done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment