|
|
|
@ -54,7 +54,10 @@ function default_settings() { |
|
|
|
|
|
|
|
|
|
function update_script() { |
|
|
|
|
header_info |
|
|
|
|
if [[ ! -d /opt/zigbee2mqtt ]]; then msg_error "No ${APP} Installation Found!"; exit; fi |
|
|
|
|
if [[ ! -d /opt/zigbee2mqtt ]]; then |
|
|
|
|
msg_error "No ${APP} Installation Found!" |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
cd /opt/zigbee2mqtt |
|
|
|
|
|
|
|
|
|
stop_zigbee2mqtt() { |
|
|
|
@ -87,21 +90,36 @@ fi |
|
|
|
|
stop_zigbee2mqtt |
|
|
|
|
|
|
|
|
|
echo "Generating a backup of the configuration..." |
|
|
|
|
cp -R data data-backup || { echo "Failed to create backup."; exit 1; } |
|
|
|
|
cp -R data data-backup || { |
|
|
|
|
echo "Failed to create backup." |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "Initiating update" |
|
|
|
|
if ! git pull; then |
|
|
|
|
echo "Update failed, temporarily storing changes and trying again." |
|
|
|
|
git stash && git pull || (echo "Update failed even after storing changes. Aborting."; exit 1) |
|
|
|
|
git stash && git pull || ( |
|
|
|
|
echo "Update failed even after storing changes. Aborting." |
|
|
|
|
exit 1 |
|
|
|
|
) |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo "Acquiring necessary components..." |
|
|
|
|
npm ci || { echo "Failed to install necessary components."; exit 1; } |
|
|
|
|
npm ci || { |
|
|
|
|
echo "Failed to install necessary components." |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "Restoring configuration..." |
|
|
|
|
cp -R data-backup/* data || { echo "Failed to restore configuration."; exit 1; } |
|
|
|
|
cp -R data-backup/* data || { |
|
|
|
|
echo "Failed to restore configuration." |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rm -rf data-backup || { echo "Failed to remove backup directory."; exit 1; } |
|
|
|
|
rm -rf data-backup || { |
|
|
|
|
echo "Failed to remove backup directory." |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
start_zigbee2mqtt |
|
|
|
|
|
|
|
|
|