-   Programming (
-   -   Howto start script at boot ? (

hendrixx 11-08-2005 06:51 AM

Howto start script at boot ?

I have a SuSE 9.3 Prof. install and have my own firewall script, therefore i have disabled SuSEFirewall2.
What i would like to do at bootime is check if my network, dhcp and Samba is up and running and then start my firewall script.
I have my script in /etc/init.d and added my firewall script with Yast2 (start at runlevel 3 wich is my default runlevel), but my firewall script is always executed before my network, dhcp and Samba is up and therefore i always need to start my firewall script manually after i have logged in.
Can someone help me out please?


PsypherPunk 11-08-2005 07:22 AM

Is there a boot.local file in init.d? i think (though may be wrong) that the contents of this get executed at the required time.

john2 11-08-2005 10:33 AM

Put a symbolic link from /etc/rc3.d (for runlevel 3 - if not change the 3 to 1, 2, 4 or 5) to your script in /etc/init.d. The name of the link should begin with S (upper case) followed by 2 numbers. The scripts are executed in the order of the names of the links, so S50xyz will run before S51abc.
I am not familiar with SuSE, so Yast2 may already have put a link there, in which case you probably just need to rename it.

hendrixx 11-15-2005 01:42 PM

Hi all,

Sorry for the late response but i was ill :-(

I tried your suggestions but with no luck, however i have found a nice solution that works for me.
After some searching on internet i found some more info and have written a little script to
check if network is up and then start my firewall.

Here's my script :


#! /bin/sh
# Provides:          Firewall
# Required-Start:    $network $syslog
# Default-Start:    3 5
# Default-Stop:      0 1 2 6
# Short-Description: Custom IPTables Firewall Rules
# Description:      Starting Firewall
# continued on second line by '#<TAB>'
# should contain enough info for the runlevel editor
# to give admin some idea what this service does and
# what it's needed for ...
# (The Short-Description should already be a good hint.)


test -x $DAEMON || exit 0

. /etc/rc.status

case "$1" in
    echo -n "Starting Firewall: "
    start-stop-daemon --start --pidfile /var/run/ --exec $DAEMON
    rc_status -v
    echo -n "Shutting down Firewall:"
    `iptables --flush`
    rc_status -v

    echo -n "Restarting Firewall: "
    echo -n "...shutting down Firewall..."
    `iptables --flush`
    rc_status -v
    echo -n "Starting Firewall: "
    start-stop-daemon --start --pidfile /var/run/ --exec $DAEMON
    rc_status -v

    echo "Usage: $0 {start|stop|restart}"
    exit 1
exit 0

The pidfile option does not seem to work, but i believe that's because its only a set of firewall rules
and not really a executable.


All times are GMT -5. The time now is 05:22 PM.