diff --git a/src/Misc/layoutbin/systemd.svc.sh.template b/src/Misc/layoutbin/systemd.svc.sh.template index df4fa5153..4361a1a1e 100644 --- a/src/Misc/layoutbin/systemd.svc.sh.template +++ b/src/Misc/layoutbin/systemd.svc.sh.template @@ -106,18 +106,30 @@ function stop() function uninstall() { - stop - systemctl disable ${SVC_NAME} || failed "failed to disable ${SVC_NAME}" - rm "${UNIT_PATH}" || failed "failed to delete ${UNIT_PATH}" + if service_exists; then + stop + systemctl disable ${SVC_NAME} || failed "failed to disable ${SVC_NAME}" + rm "${UNIT_PATH}" || failed "failed to delete ${UNIT_PATH}" + else + echo "Service ${SVC_NAME} is not installed" + fi if [ -f "${CONFIG_PATH}" ]; then rm "${CONFIG_PATH}" || failed "failed to delete ${CONFIG_PATH}" fi systemctl daemon-reload || failed "failed to reload daemons" } +function service_exists() { + if [ -f "${UNIT_PATH}" ]; then + return 0 + else + return 1 + fi +} + function status() { - if [ -f "${UNIT_PATH}" ]; then + if service_exists; then echo echo "${UNIT_PATH}" else