Koozali.org: home of the SME Server

Add service at boot

Offline stian

  • ***
  • 64
  • +0/-0
Add service at boot
« on: February 15, 2007, 03:30:57 PM »
I have a service I want to start at boot.

/usr/local/sbin/archttp32

Can anyone guide me to do this correct on smeserver? So it stays like that after upgrades etc..

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Add service at boot
« Reply #1 on: February 15, 2007, 04:18:00 PM »
Quote from: "stian"
I have a service I want to start at boot.

/usr/local/sbin/archttp32

Can anyone guide me to do this correct on smeserver? So it stays like that after upgrades etc..
See the developers guide, chapter 9: http://mirror.contribs.org/smeserver/contribs/gordonr/devguide/html/c830.htm
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline stian

  • ***
  • 64
  • +0/-0
Add service at boot
« Reply #2 on: February 15, 2007, 04:26:31 PM »
I found some tips around on the net. Could it be done like this?

# vi /etc/rc.d/init.d/areca

Enter this in this file:


---------------------------------------

#! /bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/archttp32
NAME=archttp32
DESC="Areca RAID controller management interface"

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

set -e

case "$1" in
  start)
        log_begin_msg "Starting $DESC..."
        start-stop-daemon --start --quiet -b -m --pidfile /var/run/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS 2>/dev/null || log_end_msg 1
        log_end_msg 0
        ;;
  stop)
        log_begin_msg "Stopping $DESC..."
        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
            -s INT --exec $DAEMON --oknodo || log_end_msg 1
        sleep 5
        log_end_msg 0
        ;;
  restart|force-reload)
        log_begin_msg "Restarting $DESC..."
        start-stop-daemon --stop --quiet --exec $DAEMON --pidfile \
                /var/run/$NAME.pid --oknodo
        sleep 6
        start-stop-daemon --start -m -b --quiet --pidfile \
                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || log_end_msg 1
        log_end_msg 0
        ;;
  *)
        N=/etc/init.d/$NAME
        # echo "Usage: $N {start|stop|restart|force-reload}" >&2
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0


-------------------------------

# cd /etc/rc.d/rc7.d
# ln -s /etc/rc.d/init.d/areca S95areca
# /sbin/e-smith/config set areca service InitscriptOrder 95 status enabled

I tried it just now, but it gives me an error when the service should start. Cant find the error in the log though... Could it be in the /etc/rc.d/init.d/areca script?

Offline stian

  • ***
  • 64
  • +0/-0
Add service at boot
« Reply #3 on: February 15, 2007, 04:29:47 PM »
Thanks cactus, but I am a beginner in linux, so I don`t get so much of the out of the developers guide... :oops:

Offline stian

  • ***
  • 64
  • +0/-0
Add service at boot
« Reply #4 on: February 16, 2007, 07:35:51 AM »
Tried this in  /etc/rc.d/init.d/areca:


#! /bin/sh

depend() {
        use net logger
}

start() {
        ebegin "Starting Areca Webserver"
        start-stop-daemon --start --quiet --exec /usr/local/sbin/archttp32 > /dev/null&
        eend $?
}

stop() {
        ebegin "Stopping Areca Webserver"
        start-stop-daemon --stop -s INT --exec /usr/local/sbin/archttp32
        sleep 5
        eend $?
}


No error, but it does not seem to start.