linux启动脚本被拒绝,linux重启了,服务起不来了,请问应该启动哪些脚本啊

把下面的IM_SERVER_PATH改成你自己的im_server的目录,然后把这段脚本保存为tt.sh

开启TT服务,sh tt.sh start,关闭TT服务,sh tt.sh stop即可。

#!/bin/bash

this is a start scripts for TeamTalk

author: eason

date: 11/19/2015

setup im-server 下方的IM_SERVER_PATH请替换为您的TT安装路径

IM_SERVER=im-server-*

IM_SERVER_PATH=/home/eason/Teamtalk2/source/TeamTalk-master/auto_setup/im_server

FILE_SERVER=file_server

LOGIN_SERVER=login_server

MSG_SERVER=msg_server

ROUTE_SERVER=route_server

MSFS_SERVER=msfs

HTTP_MSG_SERVER=http_msg_server

PUSH_SERVER=push_server

DB_PROXY_SERVER=db_proxy_server

print_hello(){

echo "==========================================="

echo "start all servers for TeamTalk"

echo "==========================================="

}

run_nginx() {

ps -ef | grep -v 'grep' | grep nginx

if [ $? -eq 0 ]; then

echo "Warning: nginx is running."

return 0

fi

/etc/init.d/nginx start

service nginx start

ps -ef | grep -v 'grep' | grep nginx

if [ $? -eq 0 ]; then

echo "run nginx successed."

else

echo "Error: run nginx failed."

exit 1

fi

}

stop_nginx() {

ps -ef | grep -v 'grep' | grep nginx

if [ $? -eq 0 ]; then

echo "nginx is running.start to stop..."

return 0

fi

/etc/init.d/nginx stop

service nginx stop

ps -ef | grep -v 'grep' | grep nginx

if [ $? -eq 0 ]; then

echo "stop nginx successed."

else

echo "Error: stop nginx failed."

exit 1

fi

}

run_phpfpm() {

ps -ef | grep -v 'grep' | grep php-fpm

if [ $? -eq 0 ]; then

echo "warning: php-fpm is running."

return 0

fi

cd /usr/local/php5/sbin

./php-fpm -c /usr/local/php5/etc/php.ini -y /usr/local/php5/etc/php-fpm.conf

/etc/init.d/php-fpm start

ps -ef | grep -v 'grep' | grep php-fpm

if [ $? -eq 0 ]; then

echo "run php-fpm successed."

else

echo "Error: run php-fpm failed."

exit 1

fi

}

stop_phpfpm() {

ps -ef | grep -v 'grep' | grep php-fpm

if [ $? -eq 0 ]; then

echo "warning: php-fpm is running.start to stop..."

fi

/etc/init.d/php-fpm stop

killall php-fpm

if [ $? -eq 0 ]; then

echo "stop php-fpm successed."

else

echo "Error: stop php-fpm failed."

exit 1

fi

}

run_mysql() {

PROCESS=$(pgrep mysql)

if [ -z "$PROCESS" ]; then

echo "no mysql is running..."

#service mysql start

/etc/init.d/mysql start

if [ $? -eq 0 ]; then

echo "start mysql successed."

else

echo "Error: start mysql failed."

return 1

fi

else

echo "Warning: mysql is running"

fi

#set pwd

mysqladmin -u root password $MYSQL_PASSWORD

if [ $? -eq 0 ]; then

echo "set percona root password successed."

else

echo "Error: set percona root password failed."

return 1

fi

#create database

mysql -u root -p$MYSQL_PASSWORD < macim.sql

if [ $? -eq 0 ]; then

echo "run macim.sql successed."

cd ..

else

echo "Error: run macim.sql failed."

cd ..

return 1

fi

}

stop_mysql() {

PROCESS=$(pgrep mysql)

if [ -z "$PROCESS" ]; then

echo "Warning: no mysql is running"

else

/etc/init.d/mysql stop

service mysql stop

if [ $? -eq 0 ]; then

echo "stop mysql successed."

return 0

else

echo "Error: stop mysql failed."

return 1

fi

fi

}

run_redis() {

#eason add to check redis is running or not

PROCESS=$(pgrep redis)

if [ -z "$PROCESS" ]; then

echo "no redis is running,start run redis..."

else

echo "Warning: redis is running"

return 0

fi

/etc/init.d/redis start

/usr/local/bin/redis-server /usr/local/etc/redis.conf

ps -ef | grep -v 'grep' | grep redis-server

if [ $? -eq 0 ]; then

echo "run redis successed."

else

echo "Error: run redis failed."

exit 1

fi

}

stop_redis() {

#eason add to check redis is running or not

PROCESS=$(pgrep redis)

if [ -z "$PROCESS" ]; then

echo "no redis is running,no need to stop redis."

return 0

else

echo "redis is running,start to stop redis..."

fi

/usr/local/bin/redis-server /usr/local/etc/redis.conf

ps -ef | grep -v 'grep' | grep redis-server

/etc/init.d/redis stop

pkill -9 redis

if [ $? -eq 0 ]; then

echo "stop redis successed."

else

echo "Error: stop redis failed."

exit 1

fi

}

run_imserver() {

cd $IM_SERVER_PATH/$IM_SERVER

./restart.sh $DB_PROXY_SERVER

./restart.sh $ROUTE_SERVER

./restart.sh $FILE_SERVER

./restart.sh $MSFS_SERVER

./restart.sh $LOGIN_SERVER

./restart.sh $MSG_SERVER

./restart.sh $HTTP_MSG_SERVER

./restart.sh $PUSH_SERVER

}

stop_imserver() {

#these server no need to stop manual

pkill -9 $DB_PROXY_SERVER

pkill -9 $ROUTE_SERVER

pkill -9 $FILE_SERVER

pkill -9 $MSFS_SERVER

pkill -9 $LOGIN_SERVER

pkill -9 $MSG_SERVER

pkill -9 $HTTP_MSG_SERVER

pkill -9 $PUSH_SERVER

}

print_help() {

echo "Usage: "

echo " $0 run --- run scripts to start all servers"

}

case $1 in

start)

print_hello

run_redis

run_mysql

run_nginx

run_phpfpm

run_imserver

;;

stop)

print_hello

stop_imserver

stop_phpfpm

stop_nginx

stop_mysql

stop_redis

;;

*)

print_help

;;

esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值