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