Skip to content

Instantly share code, notes, and snippets.

@sumitdhameja
Created February 27, 2016 16:13
Show Gist options
  • Save sumitdhameja/e44907b32381cdbfb812 to your computer and use it in GitHub Desktop.
Save sumitdhameja/e44907b32381cdbfb812 to your computer and use it in GitHub Desktop.
Clone - Ubuntu
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Parameters:"
echo "1- Host (irvwebxlx01)"
echo "2- IP (10.50.7.201)"
exit 1
fi
_host=$1
_ip=$2
echo "[-] Setup $_host ($_ip)"
read -p "Are you sure? " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# Change IP
sed -i "s/address .*$/address $_ip/g" /etc/network/interfaces
# Change Hostname
sed -i "s/dc_other_hostnames=.*/dc_other_hostnames='""$_host""'/g" /etc/exim4/update-exim4.conf.conf
echo "$_host" > /etc/hostname
# Add to hostfile
echo "$_ip $_host" >> /etc/hosts
# Restart Service
# service network restart
read -p "Reboot? " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
reboot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment