home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # install a new sendmail configuration file on a host on the network
- # produce a freeze file and start a new daemon
- # usage: Install.sh [-f] [-n] [-s] [-d dir] host [cf_file]
- #
- # if -f is specified, a freeze file is not made.
- # if -n is specified, only the daemon is started.
- # if -s is specified, the remote host is assumed to have SysV ps.
- # if -d dir is specified, the cf file is rcp'd to <dir>/sendmail.cf
-
-
- dofreeze=true
- docopy=true
- bsd=true
- verbose=+x
- dir=/usr/lib
-
- while [ $# -ge 1 ]
- do
- case $1 in
- -f) dofreeze=false
- ;;
- -n) docopy=false
- ;;
- -s) bsd=false
- ;;
- -v) verbose=-x
- ;;
- -d) dir=$2
- shift
- ;;
- *) host=$1
- if [ $# -eq 2 ]
- then
- file=$2
- shift
- else
- file=$1.cf
- fi
- break
- ;;
- esac
- shift
- done
-
- if [ $# -ne 1 ]
- then
- echo 'usage: Install.sh [-f] [-n] [-s] host [file]'
- exit 1
- fi
-
-
- if $docopy
- then
- #
- # copy configuration file. If successful, freeze it; otherwise
- # the host is probably down - remove the cf file and quit
- #
- if (set $verbose; rcp $file $host:$dir/sendmail.cf)
- then
- if $dofreeze
- then
- (set $verbose; rsh $host -n /usr/lib/sendmail -bz)
- fi
- else
- echo "$0: failed for $host - quitting"
- exit 1
- fi
- fi
-
- #
- # kill off current sendmail daemon and start a new one
- #
- if $bsd
- then
- pid=`rsh $host -n ps -ax | awk ' { if ($5 == "/usr/lib/sendmail" && $6 == "-bd") print $1 }'`
- else
- pid=`rsh $host -n ps -ef | awk '/[0-9]:[0-9][0-9] \/usr\/lib\/sendmail -bd/ { print $2 }'`
- fi
-
- if [ "$pid" -gt 1 ]
- then
- (set $verbose; rsh $host -n kill $pid)
- sleep 1
- fi
-
- (set $verbose; rsh $host -n /usr/lib/sendmail -bd -q1h)
-
- exit 0
-