Skip to content

Commit 1cb822b

Browse files
authored
Fix Z-Wave JS UI script (#546)
* Revert & Updated ZWave JS UI * Tweak for StorageDB
1 parent 24cfb32 commit 1cb822b

File tree

3 files changed

+46
-47
lines changed

3 files changed

+46
-47
lines changed

ct/zwave-js-ui.sh

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,33 @@ function default_settings() {
5353
}
5454

5555
function update_script() {
56-
header_info
57-
check_container_storage
58-
check_container_resources
59-
if [[ ! -d /opt/zwave-js-ui ]]; then
60-
msg_error "No ${APP} Installation Found!"
61-
exit
62-
fi
63-
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) }')
64-
msg_info "Stopping Z-wave JS UI"
65-
systemctl stop zwave-js-ui.service
66-
msg_ok "Stopped Z-wave JS UI"
56+
header_info
57+
check_container_storage
58+
check_container_resources
59+
if [[ ! -d /opt/zwave-js-ui ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
60+
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) }')
61+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
62+
msg_info "Stopping Service"
63+
systemctl stop zwave-js-ui
64+
msg_ok "Stopped Service"
6765

68-
msg_info "Updating Z-wave JS UI"
69-
wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip &>/dev/null
70-
unzip zwave-js-ui-${RELEASE}-linux.zip &>/dev/null
71-
\cp -R zwave-js-ui-linux /opt/zwave-js-ui
72-
service_path="/etc/systemd/system/zwave-js-ui.service"
73-
echo "[Unit]
74-
Description=zwave-js-ui
75-
Wants=network-online.target
76-
After=network-online.target
77-
[Service]
78-
User=root
79-
WorkingDirectory=/opt/zwave-js-ui
80-
ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux
81-
[Install]
82-
WantedBy=multi-user.target" >$service_path
83-
msg_ok "Updated Z-wave JS UI"
66+
msg_info "Updating Z-Wave JS UI"
67+
rm -rf /opt/zwave-js-ui/*
68+
cd /opt/zwave-js-ui
69+
wget -q https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip
70+
unzip -q zwave-js-ui-${RELEASE}-linux.zip
71+
msg_ok "Updated Z-Wave JS UI"
8472

85-
msg_info "Starting Z-wave JS UI"
86-
systemctl enable --now zwave-js-ui.service
87-
msg_ok "Started Z-wave JS UI"
73+
msg_info "Starting Service"
74+
systemctl start zwave-js-ui
75+
msg_ok "Started Service"
8876

89-
msg_info "Cleanup"
90-
rm -rf zwave-js-ui-${RELEASE}-linux.zip zwave-js-ui-linux store
91-
msg_ok "Cleaned"
92-
msg_ok "Updated Successfully!\n"
93-
exit
77+
msg_info "Cleanup"
78+
rm -rf /opt/zwave-js-ui/zwave-js-ui-${RELEASE}-linux.zip
79+
rm -rf /opt/zwave-js-ui/store
80+
msg_ok "Cleaned"
81+
msg_ok "Updated Successfully!\n"
82+
exit
9483
}
9584

9685
start

install/zwave-js-ui-install.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,43 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y curl
18-
$STD apt-get install -y sudo
19-
$STD apt-get install -y mc
17+
$STD apt-get install -y \
18+
curl \
19+
sudo \
20+
mc
2021
msg_ok "Installed Dependencies"
2122

2223
msg_info "Installing Z-Wave JS UI"
23-
mkdir /opt/zwave-js-ui
24+
mkdir -p /opt/zwave-js-ui
25+
mkdir -p /opt/zwave_store
2426
cd /opt/zwave-js-ui
2527
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) }')
26-
$STD wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip
27-
$STD unzip zwave-js-ui-${RELEASE}-linux.zip
28+
wget -q https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip
29+
unzip -q zwave-js-ui-${RELEASE}-linux.zip
30+
cat <<EOF >/opt/.env
31+
ZWAVEJS_EXTERNAL_CONFIG=/opt/zwave_store/.config-db
32+
STORE_DIR=/opt/zwave_store
33+
EOF
34+
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
2835
msg_ok "Installed Z-Wave JS UI"
2936

3037
msg_info "Creating Service"
31-
service_path="/etc/systemd/system/zwave-js-ui.service"
32-
echo "[Unit]
38+
cat <<EOF > /etc/systemd/system/zwave-js-ui.service
39+
[Unit]
3340
Description=zwave-js-ui
3441
Wants=network-online.target
3542
After=network-online.target
43+
3644
[Service]
3745
User=root
3846
WorkingDirectory=/opt/zwave-js-ui
3947
ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux
48+
EnvironmentFile=/opt/.env
49+
4050
[Install]
41-
WantedBy=multi-user.target" >$service_path
42-
systemctl start zwave-js-ui
43-
$STD systemctl enable zwave-js-ui
51+
WantedBy=multi-user.target
52+
EOF
53+
systemctl enable -q --now zwave-js-ui
4454
msg_ok "Created Service"
4555

4656
motd_ssh

json/zwave-js-ui.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"updateable": true,
1010
"privileged": true,
1111
"interface_port": "8091",
12-
"documentation": null,
12+
"documentation": "https://zwave-js.github.io/zwave-js-ui/#/",
1313
"website": "https://github.com/zwave-js/zwave-js-ui#",
1414
"logo": "https://raw.githubusercontent.com/loganmarchione/homelab-svg-assets/main/assets/zwave.svg",
1515
"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.",

0 commit comments

Comments
 (0)