#!/bin/bash # # created rob@egressive.com # # copies the ISPConfig user and host files to the # spam and virus filter host # # DEBUG="true" # EGMAILDETAILS_HOME="/etc/egscripts/egmaildetails" # LASTUSERS=$EGMAILDETAILS_HOME/last_users LASTHOSTS=$EGMAILDETAILS_HOME/last_hosts LASTACCESS=$EGMAILDETAILS_HOME/last_access # ISPCONFIGUSERS="/etc/postfix/virtusertable" ISPCONFIGHOSTS="/etc/postfix/local-host-names" # ACCESSFILE="/etc/postfix/access" # SERVERNAME="smithers" # REMOTESERVER="nelson.egressive.com" #REMOTESERVER="172.16.96.35" # LOGFILE="/tmp/egmaildetails.log" # TMP=/tmp # filename only - no path TRANSPORT="transport-$SERVERNAME" RECIPIENTS="recipients-$SERVERNAME" # SCPARGS=" " # if [ "$DEBUG"xxx == "truexxx" ] then echo `date` " Starting egmaildetails" >> $LOGFILE fi for i in $LASTUSERS $LASTHOSTS do if ! [ -f $i ] then touch $i fi done # if [ "$ISPCONFIGUSERS" -nt "$LASTUSERS" ] then awk \ '! /^#/ {print $1 "\t\tOK" }' \ /etc/postfix/virtusertable > $TMP/$RECIPIENTS scp $SCPARGS $TMP/$RECIPIENTS $REMOTESERVER:/etc/postfix/ ssh $REMOTESERVER "postmap /etc/postfix/$RECIPIENTS" ssh $REMOTESERVER "postfix reload" # rm $TMP/$RECIPIENTS > /dev/null 2>&1 touch $LASTUSERS fi if [ "$ISPCONFIGHOSTS" -nt "$LASTHOSTS" ] then awk \ '! /^#/ && !/^localhost/ {print $0 "\t\tsmtp:[172.16.96.31]"}' \ $ISPCONFIGHOSTS > $TMP/$TRANSPORT scp $SCPARGS $TMP/$TRANSPORT $REMOTESERVER:/etc/postfix/ # make sure the local sites file has the right servername scp $SCPARGS $ISPCONFIGHOSTS $REMOTESERVER:$ISPCONFIGHOSTS-$SERVERNAME ssh $REMOTESERVER "postmap /etc/postfix/$TRANSPORT" ssh $REMOTESERVER "postfix reload" # rm $TMP/$TRANSPORT touch $LASTHOSTS fi if [ "$ACCESSFILE" -nt "$LASTACCESS" ] then scp $SCPARGS $ACCESSFILE $REMOTESERVER:$ACCESSFILE-$SERVERNAME ssh $REMOTESERVER "postmap $ACCESSFILE-$SERVERNAME" ssh $REMOTESERVER "postfix reload" touch $LASTACCESS true fi if [ "$DEBUG"xxx == "truexxx" ] then echo `date` "Finishing egmaildetails" >> $LOGFILE fi #