启动,停止和重启常用服务器的Bash脚本,对于每个服务器,需要根据实际的安装路径做相应的修改
#! /bin/bash Servers=(Apache2, Nginx, Resin, Tomcat, Couchbase, SVN, ActiveMQ, Mongo); Ops=(Start, Stop, Restart); currentDir=$(pwd); echo "What do you want to do?" select op in Start Stop Restart; do break; done echo "Which server do you want to $op" select server in Apache2 Nginx Resin Tomcat Couchbase SVN ActiveMQ Mongo; do break; done echo "$op $server is in progress"; if [ $op = "Start" ]; then case $server in Apache2) cd /usr/local/apache2/bin; sudo ./httpd -k stop sudo ./httpd -k start;; Resin) cd /software/devsoftware/resin-pro-4.0.39/bin; sudo ./resin.sh stop; sudo ./resin.sh start;; Nginx) cd /usr/local/nginx/sbin sudo ./nginx -s stop; sudo ./nginx;; Couchbase) cd /etc/init.d #udo ./couchbase-server stop; sudo ./couchbase-server start;; Tomcat) cd /software/devsoftware/apache-tomcat-8.0.5/bin sudo ./shutdown.sh; sudo ./startup.sh;; ActiveMQ) cd /software/devsoftware/apache-activemq-5.9.1/bin sudo ./activemq stop; sudo ./activemq start;; Mongo) cd /usr/bin; sudo ./mongod --config /etc/mongodb.conf --dbpath /home/yuzhitao/development/mongoDBdata; echo "Mongo is started and running in the backgroud, port 28017";; *) echo "Not available" esac elif [ $op = "Stop" ]; then case $server in Apache2) cd /usr/local/apache2/bin; sudo ./httpd -k stop;; Resin) cd /software/devsoftware/resin-pro-4.0.39/bin; sudo ./resin.sh stop;; Nginx) cd /usr/local/nginx/sbin; sudo ./nginx -s stop;; Couchbase) #cd /etc/init.d #sudo ./couchbase-server stop; #sudo ./couchbase-server start;; pid=$(ps -ef|grep couchbase | head -2 | tail -1 | awk -F " " {'print $2'} | awk -F " " {'print $1'}); #echo $pid; sudo kill -9 $pid; echo "The couchbase server is shut down";; Tomcat) cd /software/devsoftware/apache-tomcat-8.0.5/bin sudo ./shutdown.sh;; ActiveMQ) /software/devsoftware/apache-activemq-5.9.1/bin; sudo ./activemq stop;; *) echo "Not available" esac fi