#!/bin/sh # chkconfig: 2345 78 31 # description: DrWeb antivirus daemon # # $Id: rc.drwebd,v 1.4 2002/01/10 12:28:01 mjt Exp $ # This script can be used on many unixes, including # but not limited to Linux and Solaris. # For Linux, place it into /etc/rc.d/init.d (or /etc/init.d) # directory with name `drwebd', and run `chkconfig --add drwebd' # (on Redhat-based systems) or create symlinks from /etc/rc[234].d/ # directories manually. # # For Solaris, place it into /etc/init.d/ directory and create # symlinks -- pretty the same as above. Note as of this writing, # DrWeb does not works on Solaris. # # Can someone show me how to do this on *BSD? # if [ -f /etc/rc.d/init.d/functions ] ; then # Redhat linux or derivate initscripts . /etc/rc.d/init.d/functions else action() { echo "$1"; shift; "$@"; } success() { return 0; } failure() { return 1; } fi subsysdir=/var/lock/subsys subsys=$subsysdir/drwebd what="DrWeb Daemon" root=/var/spool/drweb exe=/drwebd pidf=$root/run/pid args="-ini:drweb32.ini" user=avdaemon uchroot=$root/uchroot [ -x $root$exe ] || exit 0 PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH cpid() { if [ -f $pidf ] && read pid < $pidf && [ -d /proc/$pid ] ; then return 0 else pid= return 1 fi } start() { # more resource limits may be needed nice \ $uchroot -u $user $root \ $exe $args \ && success startup || failure startup rc=$? chmod g+w $root/run/sock 2>/dev/null echo [ -d $subsysdir ] && touch $subsys return $rc } restart() { echo "Restarting $what:" cpid && kill $pid && sleep 1 start } rc=0 case "$1" in start) if ! cpid ; then echo "Starting $what:" start fi ;; stop) cpid && action "Stopping $what" kill $pid rm -f $subsys ;; restart) restart ;; reload) if cpid ; then action "Reloading $what" kill -1 $pid else echo "No $what running" fi ;; condrestart) cpid && restart ;; status) if cpid ; then echo "$what (pid $pid) is running..." rc=0 elif [ -f $subsys ] ; then echo "$what is not running but subsys locked" rc=2 else echo "$what is not running" rc=3 fi ;; *) echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" rc=1 ;; esac exit $rc