diff --git a/misc/zwavejs2mqtt-update.sh b/misc/zwavejs2mqtt-update.sh index f5654ba1..f72db32a 100644 --- a/misc/zwavejs2mqtt-update.sh +++ b/misc/zwavejs2mqtt-update.sh @@ -5,6 +5,22 @@ BL=`echo "\033[36m"` CM='\xE2\x9C\x94\033' GN=`echo "\033[1;92m"` CL=`echo "\033[m"` +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR + +function error_exit() { + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT +} echo -en "${GN} Updating Zwavejs2MQTT... " systemctl stop zwavejs2mqtt.service