SliTaz SliTaz Forum

You are not logged in.

#1 2011-08-08 22:34:09

nim108
Member
Registered: 2011-07-29
Posts: 12

Custom /etc/init.d/ daemon cannot daemonize on startup

I'm running into a weird issue here. I compiled a daemon (namely, vblade, which is used to share drives for ATA over Ethernet support). As with most any other daemon, it must be run as root or else it does not run. First of all, here is the script (it is basically just a total copy of crond with added functions to properly create the pid file).

---

#!/bin/sh

# /etc/init.d/vblade: Start, stop and restart vblade daemon on SliTaz, at boot

# time or with the command line.

#

# To start daemon at boot time, just put the right name in the $RUN_DAEMONS

# variable of /etc/rcS.conf and configure options with /etc/daemons.conf.

#

. /etc/init.d/rc.functions

. /etc/daemons.conf

NAME=vblade

DESC="vblade deamon"

DAEMON=/usr/sbin/vblade

OPTIONS=$VBLADED_OPTIONS

PIDFILE=/var/run/vbladed.pid

case "$1" in

  start)

    if active_pidfile $PIDFILE $NAME ; then

      echo "$NAME already running."

      exit 1

    fi

    echo -n "Starting $DESC: $NAME... "

    $DAEMON $OPTIONS >> /var/log/$NAME.log 2>&1 &

    [ -f $PIDFILE ] || pidof $NAME | awk '{ print $1 }' > $PIDFILE

    active_pidfile $PIDFILE $NAME

    status

    ;;

  stop)

    if ! active_pidfile $PIDFILE $NAME ; then

      echo "$NAME is not running."

      exit 1

    fi

    echo -n "Stopping $DESC: $NAME... "

    kill [c]cat $PIDFILE[/c]

    rm $PIDFILE

    status

    ;;

  restart)

    if ! active_pidfile $PIDFILE $NAME ; then

      echo "$NAME is not running."

      exit 1

    fi

    echo -n "Restarting $DESC: $NAME... "

    kill [c]cat $PIDFILE[/c]

    rm $PIDFILE

    sleep 2

    $DAEMON $OPTIONS >> /var/log/$NAME.log 2>&1 &

    [ -f $PIDFILE ] || pidof $NAME | awk '{ print $1 }' > $PIDFILE

    active_pidfile $PIDFILE $NAME

    status

    ;;

  *)

    echo ""

    echo -e "33[1mUsage:33[0m /etc/init.d/[c]basename $0[/c] [start|stop|restart]"

    echo ""

    exit 1

    ;;

esac

exit 0

---

Here is the problem: this does not autostart vblade on startup during the init process even though I have everything properly defined (vblade in rcS.conf and options in daemons.conf). In contrast, all my other daemons I added there (udhcpd, inetd) do. However, if I run it as root after the system is up, it executes just fine. Another strange issue, if I get rid of the "&" to daemonize the process in the line "$DAEMON $OPTIONS >> /var/log/$NAME.log 2>&1 &", it autostarts just fine with the rest of my daemons. However, this is a hack at best, because then you see /etc/init.d/vblade start listed in the process list. How do I get this daemon to autostart with init AND properly daemonize? Ideally, only /usr/sbin/vblade $OPTIONS should be listed in ps if it daemonizes properly. I tried to use the conf file that comes with the vblade .deb package, but that uses lsb functions so it does not work.

Offline

#2 2011-08-15 21:09:39

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: Custom /etc/init.d/ daemon cannot daemonize on startup

Anybody? This problem is really kicking my a$$ as I cannot figure it out for the life of me.

Offline

#3 2011-08-16 22:59:29

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: Custom /etc/init.d/ daemon cannot daemonize on startup

In both stable and cooking kernels :

tux@slitaz:~$ zcat /proc/config.gz | grep CONFIG_ATA_OVER_ETH

# CONFIG_ATA_OVER_ETH is not set

Have you recompiled the kernel so AoE will work ?

Both client and server require :

CONFIG_ATA_OVER_ETH=m

or

CONFIG_ATA_OVER_ETH=yes

Offline

#4 2011-08-16 23:06:47

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: Custom /etc/init.d/ daemon cannot daemonize on startup

Yes, I recompiled the kernel with ATA Over Ethernet support enabled. That is not the issue, the issue is with the vblade init.d script running from rcS.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.016 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]