eyanu |
11-15-2012 06:22 AM |
BUG in Bash script to automate VPS installation
Hello am writing a script that would automate a VPS installation however am getting some errors, and i need your help.
here is part of the script:
Quote:
#-------------------------------------------------------------------------------
# We first configure the HOSTNAME
#-------------------------------------------------------------------------------
read -p "Please enter your HOSTNAME (e.g. puck384): " HOSTNAME
check=`echo $HOSTNAME | grep -E "[^[:alnum:]\-]"`
if [[ "$check" != "" ]]
then
echo "$HOSTNAME is not a valid HOSTNAME"
exit 2
fi
read -p "Please enter the server domain name ($HOSTNAME.<domainname>): " FQDNNAME
check=`echo $FQDNNAME | grep -E "[^[:alnum:]\-\.-]"`
if [[ "$check" != "" ]]
then
echo "$FQDNNAME is not a valid domain name!"
exit 2
fi
# We now combine the HOSTNAME to the domain name
FQDNNAME="$HOSTNAME.$FQDNNAME"
read -p "Enter the First nameserver's IP address" nameserver1
if [[ $nameserver1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
$nameserver1
else
echo "Sorry that is not a valid IP address"
read -p "Enter the Second nameserver's IP address" nameserver2
if [[ $nameserver2 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
$nameserver2
else
echo "Sorry that is not a valid IP address"
## --here wait and first investigate how to do that
echo "Enter Diskpace in Gigabites starting with minimumn allowed space:"min
echo "Enter Diskpace in Gigabites the maximum allowed" max
## -- VPS IP address
read -p "Enter IP address for you new VPS:" IP
if [[ $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
$IP
else
echo "Sorry that is not a valid IP address"
cd /var/lib/vz/template/cache
arch=`uname -m`
if [[ "$arch" == 'x86_64']]
then
wget http://download.openvz.org/template/...minimal.tar.gz
architecture=debian-6.0-amd64-minimal
else
wget http://download.openvz.org/template/...minimal.tar.gz
architecture=debian-6.0-i386-minimal
fi
vzctl create 104 --ostemplate $architecture
vzctl set 104 --onboot yes --save
vzctl set 104 --nameserver $nameserver1 --save
vzctl set 104 --nameserver $nameserver2 --save
vzctl set 104 --hostname $FQDNNAME --save
vzctl set 104 --diskspace ${min}G:${max}G --save
vzctl set 104 --ipadd 69.64.37.212 --save
vzctl set 104 --ram 10.5G --swap 5G --save
vzctl start 104
vzctl exec 104 passwd
|
However when i run it i get:
Quote:
+ read -p 'Enter the First nameserver\'\''s IP address: ' nameserver_one
Enter the First nameserver\'s IP address: xx.xx.xx.xx
vps.sh: line 48: syntax error in conditional expression
vps.sh: line 49: syntax error near `then'
vps.sh: line 49: `then
|
Is there something am doing wrong, would really appreciate it if you pointed it out.
|