init.d 脚本不起作用......但如果我在控制台中执行它,该命令会起作用

mas*_*ssi 0 scripting linux centos inittab

如果我从命令行执行它,我有一个可以正常工作的命令......但是当我把它放在一个 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
Run Code Online (Sandbox Code Playgroud)

更新(回答几个问题):

我还添加了脚本以便在启动时使用:

chkconfig --add bluepill_script  
chkconfig --level 345 bluepill_script  on  
Run Code Online (Sandbox Code Playgroud)

Jus*_*tin 12

尝试添加

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
Run Code Online (Sandbox Code Playgroud)

到初始化脚本的顶部。