#!/bin/rc
# sets up outgoing email, run on a real console because of this first bit
cat >> /srv/fscons <<!
fsys main
srv -AWP awp
!
mount /srv/awp /n/awp
if(! test -d /n/awp) exit 'fossil -awp mount failed, you probably need to be logged in at a real console'
echo 'makes this machine into an smtp relay using rewrite.^(direct|gateway)'
bkdir = $home/backups/`{date -n}
bkfiles = (/mail/lib/remotemail /mail/lib/rewrite /mail/lib/smtpd.conf /lib/ndb/local)
mkdir -p $bkdir && echo backups of $bkfiles going in $bkdir
echo copying backups to $bakdir
cp $bkfiles $bkdir || echo backups failed
echo enter your default domain for $user@default_domain
dom = `{read | sed 's/\./\\./g'}
echo which rewrite is it to be, direct or gateway (d or g will do)
if(~ `{read} d*)
sed -e 's/YOURDOMAIN\\\.DOM/' ^`{echo -n $dom | sed 's/\./\\./g'} ^'/g' /mail/lib/rewrite.direct >> /n/awp/mail/lib/rewrite
if not
sed -e 's/YOURDOMAIN\.DOM/' ^$dom ^'/g' /mail/lib/rewrite.gateway >> /n/awp/mail/lib/rewrite
echo '/yourdomain\.dom
s/yourdomain\.dom/' ^$dom ^'/
w
q
' | ed /n/awp/mail/lib/remotemail
echo '/YOURDOM\.com
s/YOURDOM\.com/' ^$dom ^'
w
q
' | ed /n/awp/mail/lib/smtpd.conf
echo 'smtp=' ^$sysname >> /lib/ndb/local
echo adding 'smtp=' ^$sysname to /lib/ndb/local
echo 'You''ll want to look at that'
|