Differences between revisions 7 and 8
Revision 7 as of 2014-02-14 09:42:43
Size: 1456
Editor: dz
Comment:
Revision 8 as of 2017-03-27 09:57:12
Size: 1505
Editor: dz
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
user="srv_user"
Line 17: Line 19:
 #su - $user $dir/sbin/$name

Quick-and-dirty SYSV start script

 #!/bin/sh

# insert tags for dependency based boot here (see below)

name="FOO"
dir="/usr/local/$name"
pidfile="$dir/var/$name.pid"
user="srv_user"


case "$1" in
    start)
        echo "Starting $name "
        $dir/sbin/$name
        #su - $user $dir/sbin/$name
        ;;
    stop)
        echo "Shutting down $name "
        kill `cat $pidfile`
        #killall $name
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    reload)
        echo "HUPing $name"
        kill -1 `cat $pidfile`
        #killall -1 $name
        ;;
    status)
        echo "Checking for service $name "
        ps aux|grep "$name"|egrep -v "grep|status"
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 1
        ;;
esac

Tags for Dependency Based Boot

Example for Debian >= 6.0

### BEGIN INIT INFO
# Provides:          name
# Required-Start:    $remote_fs $syslog $local_fs $network
# Required-Stop:     $remote_fs $syslog $local_fs $network
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: Starts name
### END INIT INFO

Example for Redhat, CentOS:

# chkconfig: 2345 20 80
# description: name

Managing rc Scripts

  • Redhat, CentOS, Mandriva: chkconfig

  • SuSE: inssrv

  • Debian: rcconf --verbose --on service

  • *BSD: vi /etc/rc.conf (see /etc/defaults/rc.conf)

Start Script (last edited 2017-03-27 09:57:12 by dz)