mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
systemd: honor RefuseManualStart and RefuseManualStop
Fixes https://github.com/rycee/home-manager/issues/140
This commit is contained in:
parent
4fce730326
commit
bc2f2ad546
1 changed files with 34 additions and 6 deletions
|
@ -119,6 +119,18 @@ in
|
||||||
);
|
);
|
||||||
|
|
||||||
home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] ''
|
home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] ''
|
||||||
|
function isStartable() {
|
||||||
|
local service="$1"
|
||||||
|
[[ $(systemctl --user show -p RefuseManualStart "$service") == *=no ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isStoppable() {
|
||||||
|
if [[ -v oldGenPath ]] ; then
|
||||||
|
local service="$1"
|
||||||
|
[[ $(systemctl --user show -p RefuseManualStop "$service") == *=no ]]
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function systemdPostReload() {
|
function systemdPostReload() {
|
||||||
local workDir
|
local workDir
|
||||||
workDir="$(mktemp -d)"
|
workDir="$(mktemp -d)"
|
||||||
|
@ -163,19 +175,35 @@ in
|
||||||
> $servicesDiffFile || true
|
> $servicesDiffFile || true
|
||||||
|
|
||||||
local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) )
|
local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) )
|
||||||
local -a toStop=( $(grep '^-' $servicesDiffFile | cut -c2-) )
|
local -a maybeStop=( $(grep '^-' $servicesDiffFile | cut -c2-) )
|
||||||
local -a toStart=( $(grep '^+' $servicesDiffFile | cut -c2-) )
|
local -a maybeStart=( $(grep '^+' $servicesDiffFile | cut -c2-) )
|
||||||
local -a toRestart=( )
|
local -a toRestart=( )
|
||||||
|
local -a toStop=( )
|
||||||
|
local -a toStart=( )
|
||||||
|
|
||||||
for f in ''${maybeRestart[@]} ; do
|
for f in ''${maybeRestart[@]} ; do
|
||||||
if ${cfg.systemctlPath} --quiet --user is-active "$f" \
|
if isStoppable "$f" \
|
||||||
&& ! cmp --quiet \
|
&& isStartable "$f" \
|
||||||
"$oldUserServicePath/$f" \
|
&& ${cfg.systemctlPath} --quiet --user is-active "$f" \
|
||||||
"$newUserServicePath/$f" ; then
|
&& ! cmp --quiet \
|
||||||
|
"$oldUserServicePath/$f" \
|
||||||
|
"$newUserServicePath/$f" ; then
|
||||||
toRestart+=("$f")
|
toRestart+=("$f")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for f in ''${maybeStop[@]} ; do
|
||||||
|
if isStoppable "$f" ; then
|
||||||
|
toStop+=("$f")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for f in ''${maybeStart[@]} ; do
|
||||||
|
if isStartable "$f" ; then
|
||||||
|
toStart+=("$f")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
rm -r $workDir
|
rm -r $workDir
|
||||||
|
|
||||||
local sugg=""
|
local sugg=""
|
||||||
|
|
Loading…
Reference in a new issue