How to create a startup script

From: Edward Nowlan <Edward.S.Nowlan_at_williams.edu>
Date: Wed, 16 Sep 1998 09:30:45 -0400 (EDT)

Unix 4.0D

I am having trouble running startup scripts. I can invoke them once the system
is up

/sbin/rc3.d/S99autohost start

and it works fine, but when the system comes up they appear not to run, as what
they are starting is not running after the system comes up.

#!/sbin/sh
#
# Control the autohost daemon
#

PATH=/usr/local/autohost:/sbin
export PATH

case "$1" in
'start')
        set `who -r`
        if [ $9 = "S" ]; then
                if /usr/local/autohost/autohost >/dev/null 2>&1 &; then
                        echo "AUTOHOST service started"
                fi
        fi
        ;;
'stop')
        set `ps -e -o pid,command $* | grep autohost | grep perl`
        if [ "X$1" != "X" ]
        then
                /bin/kill $1
        fi

        ;;
'stop')
        set `ps -e -o pid,command $* | grep autohost | grep perl`
        if [ "X$1" != "X" ]
        then
                /bin/kill $1
        fi
        ;;
*)
        echo "usage: $0 {start|stop}"
        ;;
esac

Protection on the link is:

# ls -l S99autohost
lrwxrwxrwx 1 root bin 18 Jun 26 18:10 S99autohost ->
 ../init.d/autohost

Protection on actual file:

# ls -l /sbin/init.d/autohost
-rwxr-x--- 1 root system 496 Jun 26 18:22 /sbin/init.d/autohost

The program the script runs is as follows:

#define REAL_PATH "/usr/local/autohost/autohost.server"
main (ac,av)
     char **av;
{
  /* Fork, and have the parent exit. The child becomes the server. */
  if (fork())
    exit(0);
  execv(REAL_PATH, av);
  /* If execv fails, exit with error */
  exit(1);
}


The script /usr/local/autohost/autohost.server is a perl script.

Thanks for any help you can provide.



                                -- Edward S. Nowlan
                                   Networks and Systems Administrator
                                   Williams College
                                   Voice: 413-597-2082
                                     Fax: 413-597-4103
                                   Email: edward.nowlan_at_williams.edu
Received on Wed Sep 16 1998 - 13:37:42 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT