#!/bin/bash
function docmd()
{
#echo 'func',"$1","$2"
if [ "$1" = "nginx" ];
then
if [ "$2" = "sh" ]; then
/home/prahlad/programs/nginx-1.6.0/sbin/nginx -s stop
elif [ "$2" = "re" ]; then
/home/prahlad/programs/nginx-1.6.0/sbin/nginx
sleep 1
/home/prahlad/programs/nginx-1.6.0/sbin/nginx -s stop
else
/home/prahlad/programs/nginx-1.6.0/sbin/nginx
fi
elif [ "$1" = "php-fpm" ]
then
if [ "$2" = "sh" ]; then
pkill php-fpm
elif [ "$2" = "re" ]; then
pkill php-fpm
sleep1
/home/prahlad/programs/php-5.4/sbin/php-fpm
else
/home/prahlad/programs/php-5.4/sbin/php-fpm
fi
elif [ "$1" = "apache2" ]
then
if [ "$2" = "sh" ]; then
sudo service apache2 stop
elif [ "$2" = "re" ]; then
sudo service apache2 restart
else
sudo service apache2 start
fi
elif [ "$1" = "mysql" ]
then
if [ "$2" = "sh" ]; then
sudo service mysql stop
elif [ "$2" = "re" ]; then
sudo service mysql restart
else
sudo service mysql start
fi
else
echo "Unrecognized verb",$1,$2
fi
}
cmd=""
if [ "$1" == "restart" ]; then
cmd="re"
elif [ "$1" == "stop" ]; then
cmd="sh"
elif [ "$1" == "start" ]; then
cmd="st"
fi
for name in $@
do
if [ "$name" != "start" ] && [ "$name" != "stop" ] && [ "$name" != "restart" ]; then
docmd $name $cmd
fi
done
#!/bin/bash
# echo "$1","$2"
if [ "$1"-eq"nginx" ];
then
if [ "$2" = "stop" ];
then
echo "stop"
if [ -f "/home/allen/app/nginx/conf/mynginx.pid" ];
then
kill `cat /home/allen/app/nginx/conf/mynginx.pid`
fi
elif [ "$2" = "reload" ]; then
echo "reload" "$1"
sh /home/allen/app/server.sh nginx stop
sh /home/allen/app/server.sh nginx start
elif [ "$2" = "start" ]; then
/usr/sbin/nginx -c /home/allen/app/nginx/conf/nginx.conf -g "pid /home/allen/app/nginx/conf/mynginx.pid;error_log /home/allen/app/nginx/logs/error2.log;"
echo "start" "$1"
else echo "not command"
fi
elif [ "$1" = "fpm" ]; then
if [ "$2" = "stop" ]; then
echo "stop "
if [ -f "/home/allen/app/php-fpm/php-fpm.pid" ]; then
kill `cat /home/allen/app/php-fpm/php-fpm.pid`
fi
elif [ "$2" = "reload" ]; then
echo "reload" "$1"
sh /home/allen/app/server.sh fpm stop
sh /home/allen/app/server.sh fpm start
elif [ "$2" = "start" ]; then
/usr/sbin/php-fpm -y /home/allen/app/php-fpm/etc/php-fpm.conf
echo "start"
else echo "not command"
fi
else
echo "not command"
fi