Update zigbee2mqtt.sh
This commit is contained in:
parent
12ea2c5f36
commit
7ed5202226
@ -27,12 +27,19 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/Koenkk/zigbee2mqtt/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
|
if [[ -f ~/.zigbee2mqtt ]]; then
|
||||||
NODE_VERSION=24
|
CURRENT="$(cat ~/.zigbee2mqtt)"
|
||||||
NODE_MODULE="pnpm@$(curl -fsSL https://raw.githubusercontent.com/Koenkk/zigbee2mqtt/master/package.json | jq -r '.packageManager | split("@")[1]')"
|
elif [[ -f /opt/${APP}_version.txt ]]; then
|
||||||
setup_nodejs
|
CURRENT="$(cat /opt/${APP}_version.txt)"
|
||||||
|
rm -f /opt/${APP}_version.txt
|
||||||
|
else
|
||||||
|
CURRENT=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
RELEASE=$(curl -fsSL https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
if [[ "$RELEASE" != "$CURRENT" ]]; then
|
||||||
|
NODE_VERSION=24 NODE_MODULE="pnpm@$(curl -fsSL https://raw.githubusercontent.com/Koenkk/zigbee2mqtt/master/package.json | jq -r '.packageManager | split("@")[1]')" setup_nodejs
|
||||||
|
|
||||||
msg_info "Stopping Service"
|
msg_info "Stopping Service"
|
||||||
systemctl stop zigbee2mqtt
|
systemctl stop zigbee2mqtt
|
||||||
@ -62,6 +69,7 @@ function update_script() {
|
|||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /opt/z2m_backup
|
rm -rf /opt/z2m_backup
|
||||||
msg_ok "Cleaned up"
|
msg_ok "Cleaned up"
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user