From 1323a74db01f4909134ea20eb714e70deb945df0 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 20 Oct 2021 11:51:32 +0200 Subject: [PATCH] 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 --- release_files/post_install.sh | 9 ++++---- release_files/pre_remove.sh | 43 +++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/release_files/post_install.sh b/release_files/post_install.sh index 6342c3b1d..f96d42203 100644 --- a/release_files/post_install.sh +++ b/release_files/post_install.sh @@ -13,21 +13,23 @@ cleanInstall() { printf "\033[32m Post Install of an clean install\033[0m\n" # Step 3 (clean install), enable the service in the proper way for this platform /usr/local/bin/wiretrustee service install + /usr/local/bin/wiretrustee service start } upgrade() { printf "\033[32m Post Install of an upgrade\033[0m\n" if [ "${use_systemctl}" = "True" ]; then printf "\033[32m Stopping the service\033[0m\n" - systemctl stop wiretrustee + systemctl stop wiretrustee 2> /dev/null || true fi if [ -e /lib/systemd/system/wiretrustee.service ]; then rm -f /lib/systemd/system/wiretrustee.service systemctl daemon-reload fi # will trow an error until everyone upgrade - /usr/local/bin/wiretrustee service uninstall + /usr/local/bin/wiretrustee service uninstall 2> /dev/null || true /usr/local/bin/wiretrustee service install + /usr/local/bin/wiretrustee service start } # Check if this is a clean install or an upgrade @@ -45,12 +47,9 @@ case "$action" in cleanInstall ;; "2" | "upgrade") - printf "\033[32m Post Install of an upgrade\033[0m\n" upgrade ;; *) - # $1 == version being installed - printf "\033[32m install\033[0m" cleanInstall ;; esac \ No newline at end of file diff --git a/release_files/pre_remove.sh b/release_files/pre_remove.sh index 6ac324baa..b6dc755ea 100644 --- a/release_files/pre_remove.sh +++ b/release_files/pre_remove.sh @@ -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 \ No newline at end of file + 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