I'm writing my first bash script ever. My boss wanted me to automate a install CD for our costumers.
we send out boxes, and they boot off a mkcdrec made image.
The script ask them for their IP, mask and gateway.
When they enter their info I want the script to check that they have typed in a valid IP, mask and gateway.
I have read up on regex, but its way over my head.
Im very interested in learning this, so if anyone could point me in the right direction it would be great.
But for now, can anyone try to explain this to me, with some examples and plain English
I know this script prolly could be written in two lines. But I need to do it like this so I can see what happens step by step. And keep in mind, I'm new to this
echo "Please enter your IP adress"
echo -n "Enter ip:"
echo "Please enter subnetmask"
echo -n "Enter subnetmask:"
echo "Please enter gateway"
echo -n "Enter gateway:"
echo "Please verify your settings!"
echo -n "is the above settings correct? yes/no:"
if [ "$answer" = "yes" ];then
echo "setting new configuration now"
sed "s/new-ip/$ip/" rc.inet1.conf-template > rc.inet1.conf.tmp1
sed "s/new-subnet/$subnetmask/" rc.inet1.conf.tmp1 > rc.inet1.conf.tmp2
sed "s/new-gateway/$gateway/" rc.inet1.conf.tmp2 > rc.inet1.conf.tmp
mv rc.inet1.conf.tmp rc.inet1.conf
rm rc.inet1.conf.tmp1 ; rm rc.inet1.conf.tmp2
echo "restarting configuration"