mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
systemd: handle missing service directories
Before it suggested to restart a service `*.service`, which is quite silly.
This commit is contained in:
parent
86217419e7
commit
550d0e81c9
1 changed files with 30 additions and 4 deletions
|
@ -71,16 +71,42 @@ in
|
|||
|
||||
home.activation.reloadSystemD = ''
|
||||
function systemdPostReload() {
|
||||
local servicesDiffFile="$(mktemp)"
|
||||
local workDir
|
||||
workDir="$(mktemp -d)"
|
||||
|
||||
local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user"
|
||||
local newUserServicePath="$newGenPath/home-files/.config/systemd/user"
|
||||
local oldServiceFiles="$workDir/old-files"
|
||||
local newServiceFiles="$workDir/new-files"
|
||||
local servicesDiffFile="$workDir/diff-files"
|
||||
|
||||
if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -d "$oldUserServicePath" ]]; then
|
||||
touch "$oldServiceFiles"
|
||||
else
|
||||
find "$oldUserServicePath" \
|
||||
-maxdepth 1 -name '*.service' -exec basename '{}' ';' \
|
||||
| sort \
|
||||
> "$oldServiceFiles"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$newUserServicePath" ]]; then
|
||||
touch "$newServiceFiles"
|
||||
else
|
||||
find "$newUserServicePath" \
|
||||
-maxdepth 1 -name '*.service' -exec basename '{}' ';' \
|
||||
| sort \
|
||||
> "$newServiceFiles"
|
||||
fi
|
||||
|
||||
diff \
|
||||
--new-line-format='+%L' \
|
||||
--old-line-format='-%L' \
|
||||
--unchanged-line-format=' %L' \
|
||||
<(basename -a $(echo "$oldUserServicePath/"*.service) | sort) \
|
||||
<(basename -a $(echo "$newUserServicePath/"*.service) | sort) \
|
||||
"$oldServiceFiles" "$newServiceFiles" \
|
||||
> $servicesDiffFile
|
||||
|
||||
local -a maybeRestart=( $(grep '^ ' $servicesDiffFile | cut -c2-) )
|
||||
|
@ -98,7 +124,7 @@ in
|
|||
fi
|
||||
done
|
||||
|
||||
rm $servicesDiffFile
|
||||
rm -r $workDir
|
||||
|
||||
local sugg=""
|
||||
|
||||
|
|
Loading…
Reference in a new issue