Service doesn't support chkconfig

Добрый день, программисты. У меня проблема. Помогите пожалуйста. Я создаю службу, которая должна автоматически загружаться при загрузке Linux. Поэтому я скопировал скрипт в каталог /etc/rc.d/init.d или /etc/init.d/. Но когда я выполняю команду

chkconfig --add listOfProcesses

возникает ошибка:

service  listOfProcesses doesn't support chkconfig

Вот содержание скрипта. Я нашел первую версию в Google и использовал ее в качестве образца.

#!/bin/bash
# listOfProcesses   Start the process which will show the list of processes
# chkconfig: 345 110 02
# description: This process shows current time and the list of processes
# processname: listOfProcesses
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: shows current time and the list of processes
# Description: This process shows current time and the list of processes
### END INIT INFO
# Source function library.
KIND="listOfProcesses"
    start() {
            echo -n $"Starting $KIND services: "
            daemon /home/myscript
            echo
    }   

    stop() {
            echo -n $"Shutting down $KIND services: "
            killproc /home/myscript
            echo
    }   

    restart() {
                echo -n $"Restarting $KIND services: "   
                   killproc /home/myscript
               daemon /home/myscript
               echo
    }   

    case "$1" in
      start)
              start
            ;;
      stop)
              stop
            ;;
      restart)
              restart
            ;;
      *)
            echo $"Usage: $0 {start|stop|restart}"
            exit 1
    esac
    exit $?

exit 0;

Вторая версия была сделана из cron-скрипта. Я нашел скрипт cron, скопировал его и изменил, поэтому использовал его как шаблон.

#!/bin/sh
#
# crond          Start/Stop the cron clock daemon.
#
# chkconfig: 2345 90 60
# description: cron is a standard UNIX program that runs user-specified \
#              programs at periodic scheduled times. vixie cron adds a \
#              number of features to the basic UNIX cron, including better \
#              security and more powerful configuration options.

### BEGIN INIT INFO
# Provides: crond crontab
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start:  2345
# Default-Stop: 90
# Short-Description: run cron daemon
# Description: cron is a standard UNIX program that runs user-specified 
#              programs at periodic scheduled times. vixie cron adds a 
#              number of features to the basic UNIX cron, including better 
#              security and more powerful configuration options.
### END INIT INFO

rights=whoami;
root=root;
[ -f "$rights"=="$root" ] || { 
echo "this programme requires root rights";
exit 1;
}

# Source function library.
. /etc/rc.d/init.d/functions

start() {
  echo -n $"Starting $KIND services: ";
  daemon showListOfProcesses;
}

stop() {
 echo -n $"Shutting down $KIND services: ";
 killproc showListOfProcesses;
}

restart() {
stop
start
}

reload() {
    restart;
}

force_reload() {
    # new configuration takes effect after restart
    restart
}

case "$1" in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
     restart
    ;;
reload)
    reload
    ;;
force-reload)
    force_reload
    ;;
*)
    echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
    exit 2
esac
exit $?

# Show the list of processes
function showListOfProcesses {
  top > /dev/tty2;
}

Но ситуация не изменилась. В чем проблема? Что не так в скрипте?

33
задан osgx 27 February 2011 в 14:08
поделиться