home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / uk-sendmail2.1 / Install.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-06-11  |  1.6 KB  |  90 lines

  1. #!/bin/sh
  2. # install a new sendmail configuration file on a host on the network
  3. # produce a freeze file and start a new daemon
  4. # usage: Install.sh [-f] [-n] [-s] [-d dir] host [cf_file]
  5. #
  6. # if -f is specified, a freeze file is not made.
  7. # if -n is specified, only the daemon is started.
  8. # if -s is specified, the remote host is assumed to have SysV ps.
  9. # if -d dir is specified, the cf file is rcp'd to <dir>/sendmail.cf
  10.  
  11.  
  12. dofreeze=true
  13. docopy=true
  14. bsd=true
  15. verbose=+x
  16. dir=/usr/lib
  17.  
  18. while [ $# -ge 1 ]
  19. do
  20.     case $1 in
  21.     -f)    dofreeze=false
  22.         ;;
  23.     -n)    docopy=false
  24.         ;;
  25.     -s)    bsd=false
  26.         ;;
  27.     -v)    verbose=-x
  28.         ;;
  29.     -d)    dir=$2
  30.         shift
  31.         ;;
  32.     *)    host=$1
  33.         if [ $# -eq 2 ]
  34.         then
  35.             file=$2
  36.             shift
  37.         else
  38.             file=$1.cf
  39.         fi
  40.         break
  41.         ;;
  42.     esac
  43.     shift
  44. done
  45.  
  46. if [ $# -ne 1 ]
  47. then
  48.     echo 'usage: Install.sh [-f] [-n] [-s] host [file]'
  49.     exit 1
  50. fi
  51.  
  52.  
  53. if $docopy
  54. then
  55. #
  56. #    copy configuration file.  If successful, freeze it; otherwise
  57. #    the host is probably down - remove the cf file and quit
  58. #
  59.     if (set $verbose; rcp $file $host:$dir/sendmail.cf)
  60.     then
  61.         if $dofreeze
  62.         then
  63.             (set $verbose; rsh $host -n /usr/lib/sendmail -bz)
  64.         fi
  65.     else
  66.         echo "$0: failed for $host - quitting"
  67.         exit 1
  68.     fi
  69. fi
  70.  
  71. #
  72. # kill off current sendmail daemon and start a new one
  73. #
  74. if $bsd
  75. then
  76.     pid=`rsh $host -n ps -ax | awk ' { if ($5 == "/usr/lib/sendmail" && $6 == "-bd") print $1 }'`
  77. else
  78.     pid=`rsh $host -n ps -ef | awk '/[0-9]:[0-9][0-9] \/usr\/lib\/sendmail -bd/ { print $2 }'`
  79. fi
  80.  
  81. if [ "$pid" -gt 1 ]
  82. then
  83.     (set $verbose; rsh $host -n kill $pid)
  84.     sleep 1
  85. fi
  86.  
  87. (set $verbose; rsh $host -n /usr/lib/sendmail -bd -q1h)
  88.  
  89. exit 0
  90.