From 03c65d198ed379e4bef02c7b20a4cc76207506e3 Mon Sep 17 00:00:00 2001 From: Beeranco <49772805+Beeranco@users.noreply.github.com> Date: Sat, 12 Aug 2023 04:43:39 +0200 Subject: [PATCH] Update Updater.sh Created Updater + Menu --- Updater.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Updater.sh b/Updater.sh index 8b13789..5b43182 100644 --- a/Updater.sh +++ b/Updater.sh @@ -1 +1,68 @@ +#!/bin/bash +if (whiptail --title "Updater" --yesno "This script will update and backup your packages." 8 78); then + UPDATE=yes +else + UPDATE=no +fi + +if [[ $UPDATE == no ]]; then + whiptail --title "Updater" --msgbox "Update canceled!" 8 78 + clear + exit +fi + +if grep -q Domoticz "/etc/installedmodules"; then + if (whiptail --title "Updater" --yesno "Update Domoticz?" 8 78); then + Domoticz=yes + else + echo "" + fi +fi + +if grep -q Node-RED "/etc/installedmodules"; then + if (whiptail --title "Updater" --yesno "Update Node-RED?" 8 78); then + NodeRED=yes + else + echo "" + fi +fi + +if grep -q Zigbee2MQTT "/etc/installedmodules"; then + if (whiptail --title "Updater" --yesno "Update Zigbee2MQTT?" 8 78); then + Zigbee2MQTT=yes + else + echo "" + fi +fi + +apt update +apt upgrade -y + +if [[ $Domoticz == *"yes"* ]]; then + mkdir -p /opt/backups/Domoticz + systemctl stop domoticz + cp /opt/domoticz/domoticz.db /opt/backups/Domoticz/domoticz.db + bash /opt/domoticz/updaterelease + systemctl start domoticz +fi +if [[ $NodeRED == *"yes"* ]]; then + mkdir -p /opt/backups/Node-RED + systemctl stop nodered + cp /root/.node-red/settings.js /opt/backups/Node-RED/settings.js + cp /root/.node-red/flows.json /opt/backups/Node-RED/flows.json + npm install -g --unsafe-perm node-red + systemctl start nodered +fi +if [[ $Zigbee2MQTT == *"yes"* ]]; then + mkdir -p /opt/backups/Zigbee2MQTT + systemctl stop zigbee2mqtt + cp /opt/zigbee2mqtt/data/configuration.yaml /opt/backups/Zigbee2MQTT/configuration.yaml + cp /opt/zigbee2mqtt/data/coordinator_backup.json /opt/backups/Zigbee2MQTT/coordinator_backup.json + cp /opt/zigbee2mqtt/data/database.db /opt/backups/Zigbee2MQTT/database.db + cd /opt/zigbee2mqtt + git pull + npm ci + cd ~ + systemctl start zigbee2mqtt +fi