diff --git a/ct/zwave-js-ui.sh b/ct/zwave-js-ui.sh index 8bb0624e..c5375fad 100644 --- a/ct/zwave-js-ui.sh +++ b/ct/zwave-js-ui.sh @@ -53,44 +53,33 @@ function default_settings() { } function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/zwave-js-ui ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - msg_info "Stopping Z-wave JS UI" - systemctl stop zwave-js-ui.service - msg_ok "Stopped Z-wave JS UI" +header_info +check_container_storage +check_container_resources +if [[ ! -d /opt/zwave-js-ui ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then +msg_info "Stopping Service" +systemctl stop zwave-js-ui +msg_ok "Stopped Service" - msg_info "Updating Z-wave JS UI" - wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip &>/dev/null - unzip zwave-js-ui-${RELEASE}-linux.zip &>/dev/null - \cp -R zwave-js-ui-linux /opt/zwave-js-ui - service_path="/etc/systemd/system/zwave-js-ui.service" - echo "[Unit] - Description=zwave-js-ui - Wants=network-online.target - After=network-online.target - [Service] - User=root - WorkingDirectory=/opt/zwave-js-ui - ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux - [Install] - WantedBy=multi-user.target" >$service_path - msg_ok "Updated Z-wave JS UI" +msg_info "Updating Z-Wave JS UI" +rm -rf /opt/zwave-js-ui/* +cd /opt/zwave-js-ui +wget -q https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip +unzip -q zwave-js-ui-${RELEASE}-linux.zip +msg_ok "Updated Z-Wave JS UI" - msg_info "Starting Z-wave JS UI" - systemctl enable --now zwave-js-ui.service - msg_ok "Started Z-wave JS UI" +msg_info "Starting Service" +systemctl start zwave-js-ui +msg_ok "Started Service" - msg_info "Cleanup" - rm -rf zwave-js-ui-${RELEASE}-linux.zip zwave-js-ui-linux store - msg_ok "Cleaned" - msg_ok "Updated Successfully!\n" - exit +msg_info "Cleanup" +rm -rf /opt/zwave-js-ui/zwave-js-ui-${RELEASE}-linux.zip +rm -rf /opt/zwave-js-ui/store +msg_ok "Cleaned" +msg_ok "Updated Successfully!\n" +exit } start diff --git a/install/zwave-js-ui-install.sh b/install/zwave-js-ui-install.sh index 02036ea0..df366e32 100644 --- a/install/zwave-js-ui-install.sh +++ b/install/zwave-js-ui-install.sh @@ -14,33 +14,43 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc +$STD apt-get install -y \ + curl \ + sudo \ + mc msg_ok "Installed Dependencies" msg_info "Installing Z-Wave JS UI" -mkdir /opt/zwave-js-ui +mkdir -p /opt/zwave-js-ui +mkdir -p /opt/zwave_store cd /opt/zwave-js-ui RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -$STD wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip -$STD unzip zwave-js-ui-${RELEASE}-linux.zip +wget -q https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip +unzip -q zwave-js-ui-${RELEASE}-linux.zip +cat </opt/.env +ZWAVEJS_EXTERNAL_CONFIG=/opt/zwave_store/.config-db +STORE_DIR=/opt/zwave_store +EOF +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Installed Z-Wave JS UI" msg_info "Creating Service" -service_path="/etc/systemd/system/zwave-js-ui.service" -echo "[Unit] +cat < /etc/systemd/system/zwave-js-ui.service +[Unit] Description=zwave-js-ui Wants=network-online.target After=network-online.target + [Service] User=root WorkingDirectory=/opt/zwave-js-ui ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux +EnvironmentFile=/opt/.env + [Install] -WantedBy=multi-user.target" >$service_path -systemctl start zwave-js-ui -$STD systemctl enable zwave-js-ui +WantedBy=multi-user.target +EOF +systemctl enable -q --now zwave-js-ui msg_ok "Created Service" motd_ssh diff --git a/json/zwave-js-ui.json b/json/zwave-js-ui.json index 52d8f0fd..20e6ba1a 100644 --- a/json/zwave-js-ui.json +++ b/json/zwave-js-ui.json @@ -9,7 +9,7 @@ "updateable": true, "privileged": true, "interface_port": "8091", - "documentation": null, + "documentation": "https://zwave-js.github.io/zwave-js-ui/#/", "website": "https://github.com/zwave-js/zwave-js-ui#", "logo": "https://raw.githubusercontent.com/loganmarchione/homelab-svg-assets/main/assets/zwave.svg", "description": "Z-Wave JS UI is an open-source software that serves as a gateway between Z-Wave devices and MQTT (Message Queuing Telemetry Transport) protocol, allowing users to control and monitor their Z-Wave devices via a user interface. The software provides a configurable platform to manage Z-Wave networks and integrate with other smart home systems through MQTT.",