HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=4)
-   -   init.d script worked OK on Ubuntu 10.10 but not on 11.10 despite LBS header correct (http://www.howtoforge.com/forums/showthread.php?t=55449)

talkingnews 18th December 2011 22:58

init.d script worked OK on Ubuntu 10.10 but not on 11.10 despite LBS header correct
 
On Ubuntu 11.10, if I run /usr/bin/cserver -c /etc/cserver.conf & the service runs fine.

But if I run service cserver start or /etc/init.d/cserver start as I did on 10.10, it won't. It just says "starting cServer", and that's the last I hear of it.

Here's the script:

Code:

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          cserver
# Required-Start:    $remote_fs $syslog
# Required-Stop:    $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:      $network $time
# Default-Start:    3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: Start and stop the cserver server daemon
# Description:      Controls the cserver server daemon
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}

CSERVERDIR=/usr/bin
PROG=./cserver
OPTIONS=" -c /etc/cserver.conf > /dev/null 2>&1 &"

start() {
          echo -n "Starting cServer "
          cd $CSERVERDIR
      daemon $PROG $OPTIONS
          RETVAL=$?
          echo
          return $RETVAL
}
stop() {
          CSERVERPID=$(pidof cserver)
          if [ $CSERVERPID ] ; then
        echo -n "Stopping cServer "
            kill $(pidof cserver)
            RETVAL=$?
          else
            echo "cServer not running"
            RETVAL=1
          fi
          echo
          return $RETVAL
}
status() {
          CSERVERPID=$(pidof cserver)
          if [ $CSERVERPID ] ; then
            echo -n "cServer is running"
            RETVAL=0
          else
            echo -n "cServer is stopped"
            RETVAL=1
          fi
          echo
          return $RETVAL
}

# See how we were called.
RETVAL=0

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

exit $?

Although I never had to do this on the original server, and sysv-rc-conf showed it present in the list and starting at the right levels, I manually tried doing the update-rc.d and it complained about an invalid lsb header, which led me to this question and guide. So I changed the header as above, and here's what it looked like before:

Code:

#!/bin/bash
#
#
# chkconfig: 345 99 99
#
# description: cserver init
# processname: cserver

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

Now, there's that line about "Source function library", but that directory doesn't even exist and the line is commented out anyway.

I've checked the permissions and symlinks etc on the old server, and everything seems identical.

A little bit dazed and confused now - perhaps a fresh and more knowledgaeble pair of eyes can spot something here? Thanks.


All times are GMT +2. The time now is 05:45.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.