如果我从命令行执行它,我有一个可以正常工作的命令......但是当我将它放在 init.d 脚本中时它不会启动(嗯..它启动但行为与运行时不同直接地)。
知道为什么这不适用于 init 脚本吗?
命令是:bluepill load /var/www/html/bluepill.conf
init.d 脚本是:
#!/bin/sh
## Based on http://www.novell.com/coolsolutions/feature/15380.html
# chkconfig: 345 99 1
# processname: solr
# Provides: bluepill
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: bluepill daemon, providing process monitoring
# Description: Bluepill
# Check for missing binaries
BLUEPILL_BIN=/usr/local/bin/bluepill
test -x $BLUEPILL_BIN || { echo "$BLUEPILL_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of needed config file and read it
BLUEPILL_CONFIG=/var/www/html/bluepill.conf
test -r $BLUEPILL_CONFIG || { echo "$BLUEPILL_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
case "$1" in
start)
echo -n "Starting bluepill "
$BLUEPILL_BIN load $BLUEPILL_CONFIG
;;
stop)
echo -n "Shutting down bluepill "
$BLUEPILL_BIN quit
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
更新(回答几个问题):
我还添加了脚本,以便在启动时使用:
chkconfig --add bluepill_script
chkconfig --level 345 bluepill_script on