#!/bin/sh
##编写目的:自动安装Varnish
##编写时间:2011年07月19日14:40:06
###定义变量##############
srcpath=/root/work
apppath=/usr/local
cat << EOF
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++Welcome to use Linux installed a key Varnish shells scripts ++++++++
+++++++++++++++++++++*************************+++++++++++++++++++++++
EOF
sleep 2
if
[ $UID -ne 0 ];then
echo “This script must use administrator or root user ,please exit …….”
sleep 2
exit 1
fi
Download ()
{
cd $srcpath && wget http://repo.varnish-cache.org/source/varnish-3.0.0.tar.gz #######如果是多个文件要get,那么可以这么写:wget http://repo.varnish-cache.org/source/{1.ta.gz,2.tar.gz}
echo “THIS IS STARTING SHELL MAKE INSTALL SHELL ,PLEASE WAITING ………………………..”
sleep 2s
if [ $? -eq 0 ];then
echo -n “DownLoad Linux source packages End ,Please Waiting Install………………”
else
echo -n “Download Linux source packages Failed ,Please Check………………”
fi
}
YUM_install ()
{
yum install -y automake autoconf libtool ncurses-devel libxslt groff pcre-devel pkgconfig
echo "starting install +++++++++++++++ Please wariting!"
sleep 2s
if [ $? -eq 0 ];then
echo -n "YUM install OK"
else
echo -n "YUM install failed please checking"
fi
}
Varnish30_install ()
{
cd $srcpath && tar -xzvf varnish-3.0.0.tar.gz && cd varnish-3.0.0 && ./configure --prefix=$apppath/varnishi-0.3.0 && make all &&make install
if
[ $? -eq 0 ];then
echo “This pvarnish.3.0 make install end ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
else
echo “Varnish install failed ,please check install shell or system gcc configuration ,exiting ……….”
sleep 2s
exit 1
fi
}
EXIT ()
{
echo “Now not Install ,Please exit …………………..”
exit 0
}
PS3="Please Select Install Linux Packages:"
select option in Download Varnish30_install EXIT
do
$option
done
以下上面select 的另外一种写法。
#case $i in
#Download)
#Download
#;;
#YUM_install)
#YUM_install
#;;
#Varnish30_install)
#Varnish30_install
#;;
#*)
#echo "$0 Download |YUM_install |Varnish30_install"
#;;
#esac
转载于:https://blog.51cto.com/lubing/910743