start daemon on boot - init.d script

Hey,

I compiled the LPFW ( Leopard Flower Personal Firewall) and want to start the daemon automatically on each boot. For this, I thought a init.d script would be what I need (please correct me if I’m wrong). It looks like:

lpfw.conf:


#!/bin/bash
LPFW=/usr/bin/lpfw
KILLALL=/usr/bin/killall

case "$1" in
    start)
        echo "Starting lpfw..."
        $LPFW
        ;;
    stop)
        echo "Stopping lpfw..."
        $KILLALL lpfw        
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    status) wor
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        ;;
esac

And it should be executable:

/etc/init.d> ls -l lpfw.conf 
-rwxr-xr-x 1 root root 378 Dec 26 18:42 lpfw.conf

But unfortunately, when I check after login whether lpfw is running with pgrep, I see its not. However, starting the script directly with root privileges works fine:

/etc/init.d> sudo ./lpfw.conf start
Starting lpfw...

What am I doing wrong? are the init.d script started as root? What is the correct log to check for errors during executing these scripts?
Thanks for your help in advance!

On 2013-12-26 18:56, booo123 wrote:
>
> Hey,
>
> I compiled the LPFW ( Leopard Flower Personal Firewall) and want to
> start the daemon automatically on each boot. For this, I thought a
> init.d script would be what I need (please correct me if I’m wrong). It
> looks like:

Yep, you are wrong :slight_smile:

We no longer use systemv, but systemd. No longer /etc/init.d/* scripts.

There is a chapter on the book for it.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” (Elessar))

To start on boot you need scripts under /etc/init.d/rc?.d (usually it would be /etc/init.d/rc3.d or rc5.d). Scripts in /etc/init.d are not used during boot directly - they are used by command chkconfig to create links in above mentioned directories. For this scripts need to have special comments that contain instructions for chkconfig. Look at some existing scripts for examples.

You forgot to mention which version of openSUSE you use. Thus you might get contradictionary answers. Some based on SysVinit and some on Systemd. :frowning: