#!/bin/sh
DIR1=/usr/src   
DIR2=/usr/local
cat << EOF
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++Welcome to use Linux installed a key LVS+KEEPALIVED shells scripts
+++++++++++++++++++++*************************++++++++++++++++++++++++
EOF
if
[ $UID -ne 0 ];then
echo °This script must use root user ,please exit--±
sleep 2
exit 0 
fi
download ()
{
cd $DIR1 && wget -c http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz http://www.keepalived.org/software/keepalived-1.2.12.tar.gz
if
[ $? = 0 ];then
echo "Download LVS Code is OK!"
else
echo "Download LVS Code is failed,Please check!"
exit 1
fi
}
ipvsadm_install ()
{
ln -s $DIR1/kernels/2.6.* $DIR1/linux 
cd $DIR1 && tar xzvf ipvsadm-1.26.tar.gz &&cd ipvsadm-1.26 && make && make install
if
[ $? -eq 0 ];then
echo "Install ipvsadm success,please waiting install keepalived ..............." 
else
echo "Install ipvsadm failed ,please check !" 
exit 1
fi
}
keepalived_install ()
{
cd $DIR1 && tar -xzvf keepalived-1.2.12.tar.gz &&cd keepalived-1.2.12 && ./configure && make && make install 
if
[ $? -eq 0 ];then
echo "Install keepalived success,please waiting configure keepalived ..............." 
else
echo "Install keepalived failed ,please check install version !" 
exit 1
fi
}
keepalived_config ()
{
cp $DIR2/etc/rc.d/init.d/keepalived  /etc/rc.d/init.d/ && cp $DIR2/etc/sysconfig/keepalived /etc/sysconfig/ && mkdir -p /etc/keepalived &&cp $DIR2/etc/keepalived/keepalived.conf /etc/keepalived/ && cp $DIR2/sbin/keepalived /usr/sbin/
if
[ $? -eq 0 ];then
echo "Keepalived system server config success!" 
else
echo "Keepalived system server config failed ,please check keepalived!" 
exit 1
fi
}
PS3="Please select Install Linux Packages:"
keepalived_config ()
{
cp $DIR2/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ && cp $DIR2/etc/sysconfig/keepalived /etc/sysconfig/ && mkdir -p /etc/keepalived &&cp $DIR2/etc/keepalived/keepalived.conf /etc/keepalived/ && cp $DIR2/sbin/keepalived /usr/sbin/
if
[ $? -eq 0 ];then
 
echo "Keepalived system server config success!"
else
echo "Keepalived system server config failed ,please check keepalived!"
exit 1
fi
 
}
 
PS3="Please select Install Linux Packages:"
 
select option in download ipvsadm_install keepalived_install keepalived_config
 
do
 
$option
 
done
select option in download ipvsadm_install keepalived_install keepalived_config 
do
$option
done