I created a Debian single binary package (.deb) for a software project to install the application as a service in ubuntu. dpkg --install package installation is successful in the computer I used to create the .deb package but I tried with different PC with same environment (all dependencies are installed in these 2 PCs) installation was success and all files installed to correct file locations. I triggered service serviceName start to start the service. Service successfully started but process is stopping instantly (Log message show 0xff signal received). I tried to start the process using the installed binary file in installation location (/opt/xxxx/bin directory) then process working properly. below is the init script (the script place to /etc/init.d/ directory) and is this a problem with the init script ?

summary of steps

  1. create debian package (used dh_make, dpkg-buildpackage -rfakeroot related commands)
  2. install in the same PC, installation success and service start-run-stop correctly
  3. try in different PC, installation success, service started but stop instantly.

below is the init script

# cscore daemon
# chkconfig: 345 20 80
# description: Daemon service (cscore) for cscore ubuntu 12.04
# processname: cscore


DESC="Daemon service (cscore) for CoreScanner in ubuntu 12.04"

case "$1" in
    printf "%-50s" "Starting $NAME..."
    PID=`$DAEMON > /dev/null 2>&1 & echo $!`
    #echo "Saving PID" $PID " to " $PIDFILE
        if [ -z $PID ]; then
            printf "%s\n" "Fail"
            echo $PID > $PIDFILE
            printf "%s\n" "Ok"

        printf "%-50s" "Checking $NAME..."
        if [ -f $PIDFILE ]; then
            PID=`cat $PIDFILE`
            if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
                printf "%s\n" "Process dead but pidfile exists"
                echo "Running"
            printf "%s\n" "Service not running"

        printf "%-50s" "Stopping $NAME"
            PID=`cat $PIDFILE`
            cd $DAEMON_PATH
        if [ -f $PIDFILE ]; then
            kill -HUP $PID
            printf "%s\n" "Ok"
            rm -f $PIDFILE
            printf "%s\n" "pidfile not found"

    $0 stop
    $0 start

        echo "Usage: $0 {status|start|stop|restart}"
        exit 1
  • First, /opt is "OK" but not really used in Ubuntu. This location was used in Fedora for a while, but most distros are going over to /usr/local. Second, there is really no need to "cd $DAEMON_PATH" , just call your program with the full path. Last, in your start) case , I do not see you starting anything (unless $DAEMON is starting something). Just start your program, then set $PID. Again, I highly suggest you read the packaging documentation if you ever wish to include this program in a ppa or the Debian (Ubuntu) repos. Non-standard packaging causes headaches. – Panther Jun 24 '14 at 14:44
  • Of course, if you really wish a Ubuntu package, consider using upstart. – Panther Jun 24 '14 at 14:45
  • @bodhi: Thanks and I welcome your suggestions to dig the issue. I this packaging I just need to create a package to install the application into other PC (not for repos). First I will correct the mention lines in the scripts. -Thanks – Dig The Code Jun 25 '14 at 5:21
  • @DigTheCode, Have you tried change to root sudo su then run it as /opt/../bin/.. ? – user.dz Apr 13 '15 at 11:21

Your Answer

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

Browse other questions tagged or ask your own question.