2

I am trying to make my custom made daemon run at startup and when I call update-rc.d ydcd enable

I get the error

update-rc.d: using dependency based boot sequencing
update-rc.d: error: MyDaemon Default-Start contains no runlevels, aborting.

I'm running Debian wheezy, init is SysVinit.

Googling it does not give me any valuable info, so I come here as a last resort.

What's going on here? What do I need to change in my init.d script in order to make this work?

Edit:

Here's the script:

#!/bin/bash
#
#ydcd.daemon
#
# chkconfig: 2345 85 15
# description: MyServiceName
# processname: MyServiceName
# source function library

. /lib/lsb/init-functions

RETVAL=0
NAME=ydcd.daemon
# YOU CAN SET ANY PATH BUT IS RECOMENDED TO USE THE DISTRO'S STANDARD ONE.
DAEMON=/home/debian/yd_cd/$NAME
prog=$(basename $DAEMON)
lockfile=/var/lock/$NAM

SVC_FILE=$DAEMON
start() {
    if [ -f $SVC_FILE ]; then
      #reset
      echo -n "Starting "$SVC_FILE": "
      RETVALS=$(start-stop-daemon -S -b -x $SVC_FILE -- -r)

          Count=${#RETVALS[@]}
      RETVAL="[FAIL]"

          if [ $Count -eq 0 ]; then
        RETVAL="[OK]"
      elif [ $Count -eq 1 ]; then
        if [ ${#RETVALS[0]} -eq 0 ]; then
          RETVAL="[OK]"
        else
          iStart=${#SVC_FILE}
          iLength=${#RETVALS[0]}
          Response=${RETVALS[0]:(iStart+1):7}
          RETVAL=$Response
          if [ "$Response" == "already" ]; then
            RETVAL="[OK]"
          fi
        fi
      fi
      echo $RETVAL
          return 0
    else
      echo $SVC_ALIAS" not installed" $SVC_DIR
      exit 2;
    fi
}

stop() {
    echo -n "Shutting down "$SVC_FILE":"
    RETVALS=$(start-stop-daemon -K -x $SVC_FILE -- s)
    #additional PROCKILLS=$(killall -w -q -e $SVC_PROCESS_NAME $SVC_FILENAME)
    Count=${#RETVALS[@]}
    Index=0
    RETVAL="[FAIL]"
    if [ $Count -eq 1 ]; then
        if [ ${#RETVALS[0]} -eq 0 ]; then
            RETVAL="[OK]"
        else
            Response=${RETVALS[0]:0:2}
            RETVAL=$Response
            if [ "$Response" == "No" ]; then
                RETVAL="[OK]"
            fi
        fi
    else
        RETVAL="[OK]"
    fi

    echo $RETVAL
        return 0
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $SVC_SERVICE_SCRIPT
        ;;
    restart)
        stop
        start
        ;;
    *)
    echo $SVC_ALIAS" [Invalid Startup Parameters]"
    echo "Usage:  {start|stop|status|restart}"
        exit 1
        ;;
esac
exit $?
1
1

Debian is using systemd now by default, and that has no "runlevels". Legacy commands like the one you use should work, for some value of "work".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.