Remove concrete unit files for generated ones

Podman-generated systemd unit files aren't usually generated into
`/etc/systemd/system`, and this directory is preferred for any
pre-existing unit files.
This commit is contained in:
Alex Palaistras 2023-08-12 13:15:01 +01:00
parent ee4375869d
commit 3943c51181
1 changed files with 6 additions and 2 deletions

View File

@ -73,6 +73,12 @@ function sync-systemd-services() {
if test -n "$tmp"; then buffer="${buffer}"$'\n'"${tmp}"; fi
done
# Remove concrete unit files where generated container files exist.
for unit in "$QUADLET_CONFIG_PATH"/*.container; do
tmp="$(rm --verbose --force "$SYSTEMD_CONFIG_PATH"/$(basename "${unit%.*}.service"))"
if test -n "$tmp"; then buffer="${buffer}"$'\n'"${tmp}"; fi
done
printf "%s\ndone.\n" "$buffer"
if test -n "$buffer"; then return 0; else return 1; fi
}
@ -92,8 +98,6 @@ function main() {
# Synchronize systemd services from local CoreOS home-server configuration.
printf "Synchronizing systemd service files... "
if sync-systemd-services; then
printf "Generating systemd services with Quadlet...\n"
/usr/lib/systemd/system-generators/podman-system-generator "$SYSTEMD_CONFIG_PATH"
printf "Reloading systemd daemon after service updates...\n"
systemctl daemon-reload
fi