无法加载 init.d 脚本

无法加载 init.d 脚本

我有这个 init.d 脚本

#!/bin/sh
### BEGIN INIT INFO
# Provides:          jboss
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop JBoss AS v7.0.0
### END INIT INFO
#
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
[ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh

case "$1" in
    start)
        echo "Starting JBoss AS 7.0.0"
        #original:
        #sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh

        #updated:
        start-stop-daemon --start --quiet --background --chuid charlie --exec $JBOSS_HOME/bin/standalone.sh
    ;;
    stop)
        echo "Stopping JBoss AS 7.0.0"
        #original:
        #sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown

        #updated:
        start-stop-daemon --start --quiet --background --chuid charlie --exec $JBOSS_HOME/bin/jboss-cli.sh -- --connect command=:shutdown
    ;;
    restart)
    ${0} stop
    ${0} start
    ;;
    *)
        echo "Usage: /etc/init.d/jboss {start|stop|restart}"
        exit 1
    ;;
esac

exit 0

我努力了sudo update-rc.d jboss.sh defaults

但它没有加载!我哪里做错了?我正在运行 ubuntu 10.10

答案1

您可能已将文件正确放置在 /etc/init.d 目录中,但您需要执行另一个步骤:运行 update-rc.d 以使 init 文件能够在各个运行级别中运行。

相关内容