[CLUE-Tech] Where to put SuSe Portsentry scripts?

Lynn Danielson lynnd at techangle.com
Sun Apr 1 17:29:45 MDT 2001


Kevin Cullis wrote:
> 
> I'd like to write a script for Portsentry and put it into my startup
> process, would I put it into the /etc/rc.d/boot.local file?
> 
> Basically I want Portsentry to restart automatically if I reboot my box.

I believe anything you put in boot.local will be started
before init switches into any specific runlevel.  Putting
portsentry here may be easy and not cause any problems, but 
it's more appropriate to start portsentry in those runlevels
which support networking.  

I'd probably copy an existing init script from /sbin/init.d, 
(Note that with SuSE /etc/rc.d is a link to /sbin/init.d.)
such as the one for lpd, and modify it to your needs.  Then
link it into to the specific runlevel directories with the
appropriate start and kill names.  For example, below is an
init script I modified for starting my OSS sound daemon.


#! /bin/sh
#

case "$1" in
    start)
        echo -n "Starting oss sound:"
        /usr/local/bin/soundon || return=$rc_failed
        echo -e "$return"
        ;;
    stop)
        echo -n "Shutting down oss sound:"
        /usr/local/bin/soundoff || return=$rc_failed
        echo -e "$return"
        ;;
    status)
        echo -n "Checking for /dev/sndstat: "
        cat /dev/sndstat
        ;;
    reload)
        $0 stop  &&  $0 start  ||  return=$rc_failed
        ;;
    restart)
        $0 stop  &&  $0 start  ||  return=$rc_failed
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 1
        ;;
esac
 
exit 0          


I'm not sure how portsentry works, so I can't tell you 
exactly how to modify the above script.  Perhaps you'd
want to use killall for stopping portsentry.  Perhaps a
status option isn't appropriate.  Anyway, after you've 
decided how to do that, you'll want to save the script in 
/sbin/init.d and link it into the appropriate runlevel
directories.  In your case I think that would be rc2.d
and rc3.d, since with SuSE runlevel S is single user mode,
runlevel 1 does not include networking, and runlevels 4
and 5 are undefined.  

I tend to make the things I add to runlevels start last 
die first.  In your case, let's say you named your rc 
script psentry; cd into rc2.d and execute 
ln -s ../psentry S99psentry   and
ln -s ../psentry K01psentry .  Then do the same thing
from the rc3.d directory.  Then whenever you boot into
runlevels 2 or 3 (multiuser w/networking and multiuser
with networking and graphical login, respectively) 
portsentry should get started.  If you go to runlevels
1 or S it won't be.
  
Hope this helps,

Lynn Danielson



More information about the clue-tech mailing list