fix: avoid failing and extra error messages (#136)

* avoid failing and extra error messages

* avoid extra error messages when executed after pre_remove.sh

* remove extra output and avoid failure on minor errors

* ensure the steps will run only on remove
This commit is contained in:
Maycon Santos
2021-10-20 11:51:32 +02:00
committed by GitHub
parent 74485d3b13
commit 1323a74db0
2 changed files with 32 additions and 20 deletions

View File

@@ -8,23 +8,36 @@ else
systemd_version=$(systemctl --version | head -1 | sed 's/systemd //g')
fi
printf "\033[32m Pre uninstall\033[0m\n"
remove() {
printf "\033[32m Pre uninstall\033[0m\n"
if [ "${use_systemctl}" = "True" ]; then
printf "\033[32m Stopping the service\033[0m\n"
systemctl stop wiretrustee
if [ "${use_systemctl}" = "True" ]; then
printf "\033[32m Stopping the service\033[0m\n"
systemctl stop wiretrustee || true
if [ -e /lib/systemd/system/wiretrustee.service ]; then
rm -f /lib/systemd/system/wiretrustee.service
systemctl daemon-reload || true
fi
if [ -e /lib/systemd/system/wiretrustee.service ]; then
rm -f /lib/systemd/system/wiretrustee.service
systemctl daemon-reload
fi
fi
printf "\033[32m Uninstalling the service\033[0m\n"
/usr/local/bin/wiretrustee service uninstall
printf "\033[32m Uninstalling the service\033[0m\n"
/usr/local/bin/wiretrustee service uninstall || true
if [ "${use_systemctl}" = "True" ]; then
printf "\n\033[32m running daemon reload\033[0m\n"
systemctl daemon-reload
fi
if [ "${use_systemctl}" = "True" ]; then
printf "\n\033[32m running daemon reload\033[0m\n"
systemctl daemon-reload || true
fi
}
action="$1"
case "$action" in
"0" | "remove")
remove
;;
*)
exit 0
;;
esac