寻觅生命中的那一片浅草......

RedHat/CentOS下的cherokee的启动脚本

转载的:

原文地址:http://ipbfans.org/2009/01/redhat-centos-cherokee-init-script

我根据自己的情况,做了简单修改,这个脚本适合用默认方式安装的情况

#!/bin/bash

#

# chkconfig: 2345 55 25

# description: Cherokee http server

#

. /etc/rc.d/init.d/functions

RETVAL=0

prog=”cherokee”

worker=”$prog”

#base_dir=”/usr/local/cherokee”

conf_file=/etc/cherokee/cherokee.conf

bin_file=/usr/sbin/${worker}

pid_file=/var/run/cherokee.pid.worker

start() {

echo -n $”Starting $prog: ”

daemon $bin_file -C $conf_file -d && success || failure

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch /var/lock/subsys/${prog}

return $RETVAL

}

stop() {

echo -n $”Stopping $prog: ”

if [ -r “$pid_file” ]; then

if [ -n `cat $pid_file` ]; then

killproc $bin_file -TERM

else

failure $”Stopping $prog”

fi

else

failure $”Stopping $prog”

fi

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -rf /var/lock/subsys/${prog} ${pid_file}

}

restart() {

stop

sleep 1

start

}

reload() {

echo -n $”Reloading configuration of $prog: ”

killproc $bin_file -HUP

RETVAL=$?

echo

}

logrotate() {

echo -n $”Rotating logs of $prog: ”

killproc $bin_file -USR2

RETVAL=$?

echo

}

case “$1″ in

start)

start

;;

stop)

stop

;;

restart)

restart

;;

reload)

reload

;;

logrotate)

logrotate

;;

status)

status $prog

RETVAL=$?

;;

*)

echo $”Usage: $0 {start|stop|restart|reload|status|logrotate}”

exit 1

;;

esac

exit $RETVAL

在Windows里改好,用sftp传上服务器,结果报错
/etc/init.d/cherokee
-bash: /etc/init.d/cherokee: /bin/bash^M: bad interpreter: No such file or directory

将脚本编码改为UTF8,结果又报错
/etc/init.d/cherokee
: No such file or directory1: 锘?!/bin/bash
: command not founde: line 6:
: No such file or directory7: /etc/rc.d/init.d/functions
: command not founde: line 8:
: command not founde: line 16:
‘etc/init.d/cherokee: line 17: syntax error near unexpected token `{
‘etc/init.d/cherokee: line 17: `start() {
[root@localhost init.d]# /etc/init.d/cherokee
-bash: /etc/init.d/cherokee: /bin/bash^M: bad interpreter: No such file or directory

经原作者提示,这个不是编码问题,是因为win和*nix系统换行符不同导致的

尚无评论

发表评论

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930