#!/bin/bash

read -e -p "Enter Short Host Name: " SHORTHOSTNAME;
mysql -D backups -e "select * from server WHERE host='$SHORTHOSTNAME'";
read -e -p "If that is the correct server then enter the ServerID: " SERVERID;
mysql -D backups -e "select serverid, INET_NTOA(backnetip) from newbacknetip WHERE serverid='$SERVERID'";
read -e -p "Enter Server Public IP of the server: " IP;
 
echo Does this look correct?
echo Server: $SHORTHOSTNAME;
echo Server ID: $SERVERID;
echo Server IP: $IP;
 
read -e -p "Is this information correct? [y/n] " ANS;
 
if [ "$ANS" = "y" ];
        then mysql -D backups -e "update newbacknetip set backnetip = INET_ATON('$IP') where serverid='$SERVERID' limit 1";
echo IP update completed;
fi

