From 7d85d7de4570bf18fa28181496a984af38100641 Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 21 Sep 2022 17:48:01 -0400 Subject: [PATCH] Update and rename zwavejs2mqtt-update.sh to zwave-js-ui-update.sh --- misc/zwave-js-ui-update.sh | 39 ++++++++++++++++++++++++++ misc/zwavejs2mqtt-update.sh | 56 ------------------------------------- 2 files changed, 39 insertions(+), 56 deletions(-) create mode 100644 misc/zwave-js-ui-update.sh delete mode 100644 misc/zwavejs2mqtt-update.sh diff --git a/misc/zwave-js-ui-update.sh b/misc/zwave-js-ui-update.sh new file mode 100644 index 00000000..f0948ee1 --- /dev/null +++ b/misc/zwave-js-ui-update.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e +RD=`echo "\033[01;31m"` +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 Z-wave JS UI... " +systemctl stop zwave-js-ui.service +cd /opt/zwavejs2mqtt +curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d \" | wget -i - &>/dev/null +unzip zwave-js-ui-v*.zip zwave-js-ui &>/dev/null +echo -e "${CM}${CL} \r" + +echo -en "${GN} Cleanup... " +rm zwave-js-ui-v*.zip +systemctl --system daemon-reload +systemctl start zwave-js-ui.service +echo -e "${CM}${CL} \n" + +echo -e "${GN} Finished ${CL}" + diff --git a/misc/zwavejs2mqtt-update.sh b/misc/zwavejs2mqtt-update.sh deleted file mode 100644 index cf02af01..00000000 --- a/misc/zwavejs2mqtt-update.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -set -e -RD=`echo "\033[01;31m"` -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 -cd /opt/zwavejs2mqtt -curl -s https://api.github.com/repos/zwave-js/zwavejs2mqtt/releases/latest | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d \" | wget -i - &>/dev/null -unzip -o zwavejs2mqtt-v*.zip zwavejs2mqtt &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Checking Service... " -SERVICE=/etc/systemd/system/zwavejs2mqtt.service -cat < $SERVICE -[Unit] -Description=ZWavejs2MQTT -Wants=network-online.target -After=network-online.target -[Service] -User=root -WorkingDirectory=/opt/zwavejs2mqtt -ExecStart=/opt/zwavejs2mqtt/zwavejs2mqtt -[Install] -WantedBy=multi-user.target -EOF -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleanup... " -rm zwavejs2mqtt-v*.zip -systemctl --system daemon-reload -systemctl start zwavejs2mqtt.service -systemctl enable zwavejs2mqtt.service &>/dev/null -echo -e "${CM}${CL} \n" - -echo -e "${GN} Finished ${CL}" -