#!/bin/bash oldname=`grep .local /etc/hosts | cut -f 4 -d '.' | head -n 1 | sed 's/^.* //'` clear echo "This server's current name: $oldname" echo "Enter the new server name :" read newname echo " " echo "This script will change the server name from $oldname to $newname." echo "The server will then reboot to apply the new settings." read -p "If everything above is correct, press Enter. Or Ctrl-C to abort." sed -i 's|'$oldname'.local|'$newname'.local|g' /etc/hosts sed -i 's|'$oldname'.local|'$newname'.local|g' /etc/sysconfig/network sed -i 's|'$oldname'.local|'$newname'.local|g' /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i 's|'$oldname'.local|'$newname'.local|g' /etc/asterisk/vm_general.inc echo " " echo "The server's name has been changed to: $newname." echo "The change will not take affect until you reboot." read -p "To reboot your server NOW, press Enter. Or Ctrl-C to exit." reboot