5 # NOTE: This package name detection will only work on Debian.
6 # If this postinst script ever starts doing work on Red Hat,
7 # we'll need to adapt this code accordingly.
8 script="$(basename "$0")"
9 pkg="${script%.postinst}"
10 systemd_unit="${pkg}.service"
14 if [ -e /run/systemd/system ]; then
15 eval "$(systemctl -p UnitFileState show "$systemd_unit")"
16 case "$UnitFileState" in
18 systemctl enable "$systemd_unit"
19 # Failing to start the service is not a package error,
20 # so don't let an error here propagate up.
21 systemctl start "$systemd_unit" || true
24 systemctl reload-or-try-restart "$systemd_unit" || true