emulab/mail/sendmail-install.sh
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #!/bin/sh
       
     2 
       
     3 cluster=$1
       
     4 num=$2
       
     5 mode=$3
       
     6 
       
     7 if [ -z "$cluster" -o -z "$num" -o -z "$mode" ] ; then
       
     8     echo "usage: $0 cluster num mode"
       
     9     exit 1
       
    10 fi
       
    11 
       
    12 i=0
       
    13 
       
    14 last=$(($num-1))
       
    15 last2=$(($num-2))
       
    16 
       
    17 while [ $i != $num ] ; do
       
    18 
       
    19 j=$(($i + 1))
       
    20 echo "Installing sendmail config on node $i..."
       
    21 
       
    22 if [ ! $i == $last ] ; then
       
    23 if [ $mode == "hop" ] ; then
       
    24     smarthost=node-$j-links-$i-$j
       
    25 else
       
    26     smarthost=node-$last-links-$last2-$last
       
    27 fi
       
    28 else
       
    29     smarthost=
       
    30 fi
       
    31 
       
    32 sed "s/__SMART_HOST__/$smarthost/" < sendmail.cf.template > /tmp/sendmail.cf.$i
       
    33 
       
    34 node=node-$i.$cluster.dtn.emulab.net
       
    35 
       
    36 ssh $node sudo /etc/init.d/sendmail stop
       
    37 
       
    38 scp /tmp/sendmail.cf.$i $node:/tmp/sendmail.cf
       
    39 ssh $node sudo cp /tmp/sendmail.cf /etc/mail/sendmail.cf
       
    40 
       
    41 ssh $node sudo find /var/spool/mqueue/ -type f -delete   
       
    42 ssh $node sudo find /var/spool/clientmqueue/ -type f -delete   
       
    43 ssh $node rm -f /var/log/maillog
       
    44 
       
    45 ssh $node sudo rm -rf /var/run/sendmail_host_status
       
    46 ssh $node sudo mkdir /var/run/sendmail_host_status
       
    47 ssh $node sudo chmod 700 /var/run/sendmail_host_status
       
    48 
       
    49 scp count_delivery.sh $node:/tmp/count_delivery.sh
       
    50 
       
    51 ssh $node sh -c 'cat > /tmp/sysconfig_sendmail <<EOF
       
    52 DAEMON=yes
       
    53 QUEUE=5s
       
    54 EOF
       
    55 '
       
    56 ssh $node sudo cp /tmp/sysconfig_sendmail /etc/sysconfig/sendmail
       
    57 
       
    58 ssh $node sudo /etc/init.d/sendmail start
       
    59 
       
    60 i=$(($i + 1))
       
    61 done