From 88a5d8b798c9ae4a571f7cd548f74c4f66c5cf53 Mon Sep 17 00:00:00 2001 From: Neha Naithani Date: Thu, 25 Feb 2021 14:07:04 +1300 Subject: [PATCH] Agent upgrade script update --- .../iofog-agent/usr/share/iofog-agent/upgrade.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packaging/iofog-agent/usr/share/iofog-agent/upgrade.sh b/packaging/iofog-agent/usr/share/iofog-agent/upgrade.sh index 87bac3326..2064aafeb 100644 --- a/packaging/iofog-agent/usr/share/iofog-agent/upgrade.sh +++ b/packaging/iofog-agent/usr/share/iofog-agent/upgrade.sh @@ -23,14 +23,16 @@ get_distribution() { BACKUP="/var/backups/iofog-agent/config.xml" cp "$ORIGINAL" "$BACKUP" + # Stop agent + service iofog-agent stop + # Create backup for rollback cd /var/backups/iofog-agent tar -cvzf config_backup$iofogpackage.tar.gz -P /etc/iofog-agent tar -cvzf log_backup_upgrade$iofogversion.tar.gz -P /var/log/iofog-agent printf 'ver: %s %s' $iofogversion $iofogpackage > prev_version_data - # Stop agent - service iofog-agent stop + # remove current configs rm /etc/iofog-agent/* # Perform upgrade @@ -51,6 +53,11 @@ get_distribution() { esac # Restore config and start agent + cd /var/backups/iofog-agent + tar -xzf config_backup$iofogpackage.tar.gz + mv etc/iofog-agent/* /etc/iofog-agent/ + echo 'config restored' + cp "$BACKUP" "$ORIGINAL" starttimestamp=$(date +%s) service iofog-agent start