Ver código fonte

Update zwavejs2mqtt-update.sh

tteckster 3 anos atrás
pai
commit
2a9b48b2d5
1 arquivos alterados com 16 adições e 0 exclusões
  1. 16 0
      misc/zwavejs2mqtt-update.sh

+ 16 - 0
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