PLATFORM_IF_MATCH(solaris9\|aix5)
PLATFORM_ENDIF
PLATFORM_IF_MATCH(solaris9)
PLATFORM_ELSE_IF_MATCH(solaris8)
PLATFORM_ENDIF
"${ENCAP_SOURCE}/${ENCAP_PKGNAME}/sbin/rotate_queues.sh";
chmod 755 "${ENCAP_SOURCE}/${ENCAP_PKGNAME}/sbin/rotate_queues.sh";
]]>
${1}.pre.${ENCAP_PKGNAME}";
mv "$1" "${1}.pre.${ENCAP_PKGNAME}";
fi
}
### procedure to create a link
### usage: dolink /path/to/file ../relative/link/path
dolink() {
delete_orig "$1";
echo " linking: $1 -> $2";
ln -sf "$2" "$1";
}
### procedure to move a file
### usage: savemove /path/to/src /path/to/dest
safemove() {
if [ -f "$1" -a ! -h "$1" ]; then
echo " moving: $1 -> $2";
mv "$1" "$2";
fi
}
### procedure to change the ownership and mode of a file or directory
### usage: setperms /path/to/file mode owner group
setperms() {
echo " changing permissions: $1 ($2 ${3}:${4})";
chmod "$2" "$1";
chown "${3}:${4}" "$1";
}
### procedure to create a group
### usage: creategroup name gid
creategroup() {
# find next unused gid starting at $2
PLATFORM_IF_MATCH(sparc-solaris)
NEWGID=`/bin/nawk -F: '{ gids[$3] = 1; } END { for (n='$2'; n in gids; n++); print n; }' /etc/group`;
PLATFORM_ELSE
NEWGID=`/bin/awk -F: '{ gids[$3] = 1; } END { for (n='$2'; n in gids; n++); print n; }' /etc/group`;
PLATFORM_ENDIF
echo " creating group: $1 (gid $NEWGID)";
PLATFORM_IF_MATCH(rs6000-aix)
/usr/bin/mkgroup id="$NEWGID" "$1";
PLATFORM_ELSE_IF_MATCH(irix)
echo "${1}:*:${NEWGID}:" >> /etc/group;
PLATFORM_ELSE
/usr/sbin/groupadd -g "$NEWGID" "$1";
PLATFORM_ENDIF
}
### procedure to create a user
### usage: createuser name uid gid home gecos
createuser() {
# find next unused uid starting at $2
PLATFORM_IF_MATCH(sparc-solaris)
NEWUID=`/bin/nawk -F: '{ uids[$3] = 1; } END { for (n='$2'; n in uids; n++); print n; }' /etc/passwd`;
PLATFORM_ELSE
NEWUID=`/bin/awk -F: '{ uids[$3] = 1; } END { for (n='$2'; n in uids; n++); print n; }' /etc/passwd`;
PLATFORM_ENDIF
echo " creating user: $1 (id=$NEWUID/$3 home=$4)";
PLATFORM_IF_MATCH(rs6000-aix)
/usr/bin/mkuser id="$NEWUID" pgrp="$3" home="$4" gecos="$5" "$1";
PLATFORM_ELSE_IF_MATCH(irix)
GID=`awk -F: '$1 == "'$3'" { print $3 }' /etc/group`;
echo "${1}:x:${NEWUID}:${GID}:${5}:${4}:" >> /etc/passwd;
if [ -f /etc/shadow ]; then
echo "${1}:*LK*:::::::" >> /etc/shadow;
fi
PLATFORM_ELSE
/usr/sbin/useradd -u "$NEWUID" -g "$3" -d "$4" -c "$5" "$1";
PLATFORM_ENDIF
}
umask 022;
PATH=/bin:/usr/bin; export PATH;
echo "Checking for smmsp user and group...";
awk -F: '$1 == "smmsp" { exit(1); }' /etc/group \
&& creategroup smmsp 25;
awk -F: '$1 == "smmsp" { exit(1); }' /etc/passwd \
&& createuser smmsp 25 smmsp /var/spool/clientmqueue \
"sendmail message submission program";
echo "Setting permissions...";
setperms / 755 0 0;
setperms /etc 755 0 0;
if [ ! -d /etc/mail ]; then
echo " creating directory: /etc/mail";
mkdir /etc/mail;
fi
setperms /etc/mail 755 0 0;
setperms /var 755 0 0;
setperms /var/spool 755 0 0;
if [ ! -d /var/spool/mqueue ]; then
echo " creating directory: /var/spool/mqueue";
mkdir /var/spool/mqueue;
fi
setperms /var/spool/mqueue 755 0 0;
if [ ! -d /var/spool/clientmqueue ]; then
echo " creating directory: /var/spool/clientmqueue";
mkdir /var/spool/clientmqueue;
fi
setperms /var/spool/clientmqueue 770 smmsp smmsp;
setperms "${ENCAP_SOURCE}/${ENCAP_PKGNAME}/sbin/sendmail" 2555 0 smmsp;
echo "Creating links to Encap files...";
for n in /usr/sbin/sendmail /usr/sbin/makemap /etc/mail/helpfile; do
delete_orig ${n};
dolink ${n} ${ENCAP_TARGET}`echo ${n}|sed 's|^/usr||'`;
done
echo "Creating links to sendmail...";
for n in /usr/lib/sendmail /usr/bin/hoststat /usr/bin/purgestat \
/usr/bin/newaliases /usr/sbin/newaliases \
/usr/bin/mailq /usr/sbin/mailq; do
delete_orig ${n};
dolink ${n} /usr/sbin/sendmail;
done
if [ ! -d /usr/lib/sasl2 ]; then
ln -s /usr/local/lib/sasl2 /usr/lib
fi
echo "Creating links to makemap...";
delete_orig /usr/bin/makemap;
dolink /usr/bin/makemap /usr/sbin/makemap;
echo "Updating config file locations...";
# save sendmail.cf
grep "^##### ${ENCAP_PKGNAME} " /etc/mail/sendmail.cf > /dev/null 2>&1 \
|| delete_orig /etc/mail/sendmail.cf;
delete_orig /etc/sendmail.cf;
dolink /etc/sendmail.cf mail/sendmail.cf;
# make sure aliases file is in /etc/mail
if [ ! -f /etc/mail/aliases ]; then
safemove /etc/aliases /etc/mail/aliases;
if [ ! -f /etc/mail/aliases ]; then
touch /etc/mail/aliases;
fi
fi
dolink /etc/aliases mail/aliases
# move sendmail.st to statistics
safemove /etc/mail/sendmail.st /etc/mail/statistics;
if [ ! -f /etc/mail/statistics ]; then
safemove /etc/sendmail.st /etc/mail/statistics;
if [ ! -f /etc/mail/statistics ]; then
touch /etc/mail/statistics;
fi
fi
dolink /etc/mail/sendmail.st statistics;
# link sendmail.hf to helpfile
delete_orig /etc/mail/sendmail.hf;
dolink /etc/mail/sendmail.hf helpfile;
# move sendmail.cw to local-host-names
safemove /etc/mail/sendmail.cw /etc/mail/local-host-names;
if [ ! -f /etc/mail/local-host-names ]; then
safemove /etc/sendmail.cw /etc/mail/local-host-names;
fi
if [ -f /etc/mail/local-host-names ]; then
dolink /etc/mail/sendmail.cw local-host-names;
fi
# make sure smrsh admin directory exists
if [ ! -d /usr/adm ]; then
echo " creating directory: /usr/adm";
mkdir /usr/adm;
fi
if [ ! -f /usr/adm/sm.bin ]; then
dolink /usr/adm/sm.bin ${ENCAP_TARGET}/adm/sm.bin;
fi
# install config files
echo " installing: /etc/mail/submit-base.cf";
${ENCAP_TARGET}/bin/m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/m4/cf.m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/cf/submit.mc \
> /etc/mail/submit-base.cf
echo " installing: /etc/mail/ks-standalone.cf";
${ENCAP_TARGET}/bin/m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/m4/cf.m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/cf/ks-standalone.mc \
> /etc/mail/ks-standalone.cf
echo " installing: /etc/mail/ks-submit.cf";
${ENCAP_TARGET}/bin/m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/m4/cf.m4 \
${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/sendmail/cf/ks-submit.mc \
> /etc/mail/ks-submit.cf
# set up rc scripts
PLATFORM_IF_MATCH(rs6000-aix4)
/usr/bin/nawk '{ \
if ( $0 ~ "^start /usr/lib/sendmail" ) { \
print "# ", $0; \
if ( ! gotcha ) { \
print "/usr/sbin/sendmail -bd -q20m && echo \"started sendmail (MTA)\""; \
print "/usr/sbin/sendmail -L sm-msp -Ac -q20m && echo \"Started sendmail (MSP)\""; \
} \
gotcha = 1; \
} else if ( $0 ~ "^/usr/sbin/sendmail " ) { \
if ( ! gotcha ) { \
print "/usr/sbin/sendmail -bd -q20m && echo \"started sendmail (MTA)\""; \
print "/usr/sbin/sendmail -L sm-msp -Ac -q20m && echo \"Started sendmail (MSP)\""; \
} \
gotcha = 1; \
} else { \
print; \
} \
}' < /etc/rc.tcpip > /etc/rc.tcpip.new.$$;
cmp -s /etc/rc.tcpip /etc/rc.tcpip.new.$$;
if [ $? -ne 0 ]; then
echo " updating rc script: /etc/rc.tcpip";
delete_orig /etc/rc.tcpip;
mv /etc/rc.tcpip.new.$$ /etc/rc.tcpip;
chmod 774 /etc/rc.tcpip;
else
rm -f /etc/rc.tcpip.new.$$;
fi
PLATFORM_ELSE_IF_MATCH(rs6000-aix5)
/usr/bin/nawk '{ \
if ( $0 ~ "^start /usr/lib/sendmail" ) { \
printf "# "; \
} \
print; \
}' < /etc/rc.tcpip > /etc/rc.tcpip.new.$$;
cmp -s /etc/rc.tcpip /etc/rc.tcpip.new.$$;
if [ $? -ne 0 ]; then
echo " updating rc script: /etc/rc.tcpip";
delete_orig /etc/rc.tcpip;
mv /etc/rc.tcpip.new.$$ /etc/rc.tcpip;
chmod 774 /etc/rc.tcpip;
else
rm -f /etc/rc.tcpip.new.$$;
fi
RC_DIR="/etc/rc.d";
SCRIPT_NAME="sendmail";
OFF_LINK="K01sendmail";
OFF_LEVELS="";
ON_LINK="S99sendmail";
ON_LEVELS="2";
if [ ! -d "${RC_DIR}/init.d" ]; then
echo " creating directory: ${RC_DIR}/init.d";
mkdir "${RC_DIR}/init.d";
fi
PLATFORM_ELSE_IF_MATCH(hpux)
RC_DIR="/sbin";
SCRIPT_NAME="sendmail";
OFF_LINK="K460sendmail";
OFF_LEVELS="1";
ON_LINK="S540sendmail";
ON_LEVELS="2";
PLATFORM_ELSE_IF_MATCH(sparc-solaris)
RC_DIR="/etc";
SCRIPT_NAME="sendmail";
OFF_LINK="K36sendmail";
OFF_LEVELS="0 1 S";
ON_LINK="S88sendmail";
ON_LEVELS="2";
PLATFORM_ELSE_IF_MATCH(irix)
RC_DIR="/etc";
SCRIPT_NAME="mail";
OFF_LINK="K20mail";
OFF_LEVELS="0";
ON_LINK="S50mail";
ON_LEVELS="2";
PLATFORM_ELSE_IF_MATCH(linux)
RC_DIR="/etc/rc.d";
SCRIPT_NAME="sendmail";
OFF_LINK="K30sendmail";
OFF_LEVELS="0 1 6";
ON_LINK="S80sendmail";
ON_LEVELS="2 3 4 5";
PLATFORM_ENDIF
PLATFORM_IF_MATCH(rs6000-aix4)
PLATFORM_ELSE
SCRIPT="${RC_DIR}/init.d/${SCRIPT_NAME}";
cmp -s ${SCRIPT} ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/sendmail.rc;
if [ $? -ne 0 ]; then
echo " installing: ${SCRIPT}";
if [ -f "${SCRIPT}" ]; then
cp ${SCRIPT} ${SCRIPT}.pre.${ENCAP_PKGNAME};
fi
cp ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/sendmail.rc ${SCRIPT};
chmod +x ${SCRIPT};
for level in ${ON_LEVELS}; do
rm -f "${RC_DIR}/rc${level}.d/${ON_LINK}";
dolink "${RC_DIR}/rc${level}.d/${ON_LINK}" "../init.d/${SCRIPT_NAME}";
done
for level in ${OFF_LEVELS}; do
rm -f "${RC_DIR}/rc${level}.d/${OFF_LINK}";
dolink "${RC_DIR}/rc${level}.d/${OFF_LINK}" "../init.d/${SCRIPT_NAME}";
done
fi
PLATFORM_ENDIF
# print message about configuration
cat <
PLATFORM_IF_MATCH(rs6000-aix4)
PLATFORM_ELSE
PLATFORM_ENDIF
/etc/mail/access')dnl
FEATURE(blacklist_recipients)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(`nouucp', `reject')dnl
FEATURE(use_ct_file)dnl
dnl ### set up PH redirection
define(`DOMAINMAP_ADDRTYPE', `1')dnl
FEATURE(domainmap, `uiuc.edu', `ph -D -l 30 -h phquery.uiuc.edu')dnl
dnl ### SASL configuration stuff - bad so far
define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 PLAIN LOGIN')dnl
TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 PLAIN LOGIN')dnl
dnl ### What ports should we run on?
FEATURE(`no_default_msa')dnl turn off default entry for MSA
DAEMON_OPTIONS(`Port=587, Name=MSA, M=E')dnl
DAEMON_OPTIONS(`Port=465, Name=MTA-SSL, M=s')dnl
DAEMON_OPTIONS(`Port=25, Name=MTA')dnl
dnl ### SSL stuff
define(`CERT_DIR', `/etc/mail/certs')dnl
define(`confCACERT_PATH', `CERT_DIR')dnl
define(`confCACERT', `CERT_DIR/CAcert.pem')dnl
define(`confSERVER_CERT', `CERT_DIR/mailhost.pem')dnl
define(`confSERVER_KEY', `CERT_DIR/mailhost.key.pem')dnl
define(`confCLIENT_CERT', `CERT_DIR/mailhost.pem')dnl
define(`confCLIENT_KEY', `CERT_DIR/mailhost.key.pem')dnl
dnl ### Only allow the PLAIN/LOGIN opts if we're connecting in a secure manner
define(`confAUTH_OPTIONS', `p y')dnl
dnl ### Better compatibility with the rest of the world
define(`confTLS_SRV_OPTIONS', `V')dnl
dnl ### mailers
MAILER(`local')dnl
MAILER(`smtp')dnl
]]>
linkdir share/sendmail
exclude sbin/rotate_queues.sh.in
prereq pkgspec >= m4-1.4
prereq pkgspec >= procmail-3.22
prereq pkgspec >= db-4.1.25
prereq pkgspec >= cyrus_sasl-2.1.15
linkname sbin/qtool.pl qtool
linkname sbin/rotate_queues.sh rotate_queues