#!/bin/sh

# Time to make the backups
mkdir -p ~/tnsr-config-backup
sudo cp -p /var/tnsr/running_db ~/tnsr-config-backup/running_db-`date +%Y%m%d%H%M%S`.xml
sudo cp -p /var/tnsr/startup_db ~/tnsr-config-backup/startup_db-`date +%Y%m%d%H%M%S`.xml

# Check OS type to determine upgrade method
. /etc/os-release

case "${ID}" in
ubuntu)
	# Update via APT
	echo "Upgrading TNSR on Ubuntu"
	sudo apt update
	sudo apt full-upgrade -y
	;;
*)
	echo "Unrecognized Operating System"
	exit 1
	;;
esac

# Start services
sudo tnsrctl restart
