- . /etc/init.d/functions #调用系统函数
- yum -y install java >/dev/null
- TAR="apache-tomcat-9.0.0.M26"
- URL="http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M26/bin/${TAR}.tar.gz"
- DST="/usr/local/tomcat_test"
- cd /usr/local/src && wget $URL >/dev/null
- WGET=`echo $?`
- if [ $WGET -eq 0 ];then
- action "Download ${TAR}.tar.gz" /bin/true #对应./etc/init.d/functions 输出ok
- else
- action "Download ${TAR}.tar.gz" /bin/false 输出 no
- fi
- /bin/tar xf ${TAR}.tar.gz
- mv $TAR $DST
- cd $DST && ./bin/startup.sh >/dev/null
- START=`echo $?` # ` ` 符号表示先执行符号里内容
- if [ $START -eq 0 ];then
- action "start tomcat" /bin/true
- else
- action "start tomcat" /bin/false
- fi
来源: http://www.bubuko.com/infodetail-2294657.html