#!/bin/bash hvbuild() { groupadd --system -f smmsp groupadd --system -f mail hv_useradd --system -g smmsp -G mail smmsp chmod 1777 /var/mail mkdir -p /var/spool/mqueue mkdir -p /etc/mail cat > devtools/Site/site.config.m4 << "EOF" define(`confMANGRP',`root') define(`confMANOWN',`root') define(`confSBINGRP',`root') define(`confUBINGRP',`root') define(`confUBINOWN',`root') EOF if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then # Adding support for SASL2 and MILTER cat >> devtools/Site/site.config.m4 << "EOF" APPENDDEF(`conf_sendmail_ENVDEF', `-DSASL=2') APPENDDEF(`conf_sendmail_LIBS', `-lsasl2') APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER') EOF # Configuration file for SASL2 echo "pwcheck_method: saslauthd" /usr/lib/sasl2/Sendmail.conf fi cd sendmail sh Build cd ../ if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then cd libmilter sh Build install cd ../ fi cd cf/cf cp generic-linux.mc sendmail.mc sh Build sendmail.mc sh Build install-cf cd ../../ sh Build install if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then # Configuration Information cat > /etc/mail/sendmail.mc << "EOF" dnl include(`./m4/cf.m4') VERSIONID(`sendmail.mc Hugo Villeneuve 2003/10/06') OSTYPE(linux) DOMAIN(generic) dnl dnl ---------- Procmail settings ---------- define(`PROCMAIL_MAILER_ARGS', procmail -a $h -d $u)dnl define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail') dnl dnl ---------- Log messages level ---------- define(`confLOG_LEVEL', `14') dnl dnl ---------- confPRIVACY_FLAGS ---------- dnl "vrfy": (verify) pour verifier l'existence d'une adresse sur le serveur. dnl "expn": (expand) qui est identique a "vrfy" mais qui permet aussi de lister dnl les personnes d'une liste et autres alias. dnl "noreceipts": To disable sending DSN receipts. dnl "goaway": Disable all SMTP status queries. dnl "authwarnings": Adds x-authentication-warning. dnl "restrictmailq": mqueue group can see queue. dnl "restrictqrun": mqueue owner to run queue. dnl "nobodyreturn": Does not return mail body define(`confPRIVACY_FLAGS', `goaway authwarnings restrictmailq restrictqrun nobodyreturn novrfy noexpn noreceipts') dnl dnl ---------- Maximum message size (in bytes) ---------- define(`confMAX_MESSAGE_SIZE',10000000) dnl define(`confMAX_DAEMON_CHILDREN',`30') define(`confCONNECTION_RATE_THROTTLE',`10') define(`confMAX_RCPTS_PER_MESSAGE',`50') dnl dnl ---------- MILTER support ---------- define(`confINPUT_MAIL_FILTERS',`clmilter') dnl dnl ---------- SMTP Authorization options ---------- define(`confAUTH_OPTIONS', `A') define(`confAUTH_MECHANISMS', `LOGIN PLAIN') TRUST_AUTH_MECH(`LOGIN PLAIN') dnl dnl ---------- Don't send the version number of sendmail ---------- define(`confSMTP_LOGIN_MSG',`_HOSTNAME_') MASQUERADE_AS(_DOMAIN_) dnl Uncomment the following line to use a non-standard port dnl DAEMON_OPTIONS(`Port=_ALTERNATE_PORT_NUMBER_,Name=MTA') dnl dnl This is necessary for the local Sendmail to work, when using dnl an alternate port number: DAEMON_OPTIONS('Port=25','Name=MTA') dnl FEATURE(nouucp, nospecial) FEATURE(use_cw_file) FEATURE(`access_db', `hash -T /etc/mail/access') FEATURE(virtusertable, `hash -o /etc/mail/virtusertable') FEATURE(`local_procmail') FEATURE(`mailertable') MAILER(procmail) INPUT_MAIL_FILTER(`clmilter',`S=local:/var/clamav/clmilter.sock, F=, T=S:4m;R:4m')dnl dnl INPUT_MAIL_FILTER(`smf-spf', `S=local:/var/run/smfs/smf-spf.sock, T=S:30s;R:1m') dnl INPUT_MAIL_FILTER(`greylist',`S=local:/var/run/milter-greylist/milter-greylist.sock') MAILER(smtp) EOF sed -i -e "s!_HOSTNAME_!${MACHINE_NAME}\.${DOMAIN}!g" /etc/mail/sendmail.mc sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /etc/mail/sendmail.mc if [ -n "${SENDMAIL_INCOMING_PORT}" ]; then # Uncommenting the alternate port line sed -i -e "s!\(dnl \)\(.*_ALTERNATE_PORT_NUMBER_.*\)!\2!g" /etc/mail/sendmail.mc # Replacing the port number sed -i -e "s!_ALTERNATE_PORT_NUMBER_!${SENDMAIL_INCOMING_PORT}!g" /etc/mail/sendmail.mc fi # We must put the domain name, and not the hostname in local-host-names echo "${DOMAIN}" > /etc/mail/local-host-names if [ -n "${MAIL_ADMIN}" ]; then echo "postmaster: ${MAIL_ADMIN}" > /etc/mail/aliases else exit 1 fi cat >> /etc/mail/aliases << "EOF" mailer-daemon: postmaster abuse: postmaster root: postmaster EOF cat > /etc/mail/access << "EOF" # This is absolutely needed for each 192.168.0.x computer to send mail... Connect:192.168.0 RELAY EOF cd /etc/mail cp -R ${SRC_DIR}/cf/* . cat > /etc/mail/submit.mc << "EOF" dnl include(`./m4/cf.m4')dnl dnl EOF cat ${SRC_DIR}/cf/cf/submit.mc >> /etc/mail/submit.mc sed -i "s!\(^FEATURE.*\)127.0.0.1\(.*\)!\1${MACHINE_NAME}\.${DOMAIN}\2!" /etc/mail/submit.mc newaliases -v cat > /etc/mail/virtusertable << "EOF" # MAKE SURE ALL ENTRIES ARE SEPARATED WITH # EOF if [ -n "${SENDMAIL_ALT_MAILER}" ]; then echo ". ${SENDMAIL_ALT_MAILER}" > /etc/mail/mailertable else echo "# Define alternate mailer in this file" \ > /etc/mail/mailertable fi cat > /etc/mail/configure << "EOF" #!/bin/bash PID_FILE="/var/run/sendmail.pid" cd /etc/mail m4 sendmail.mc > sendmail.cf m4 submit.mc > submit.cf newaliases makemap hash access.db < access makemap hash virtusertable < virtusertable makemap hash mailertable.db < mailertable || exit 1 # Restarting sendmail if [ -f ${PID_FILE} ]; then kill -HUP `head -1 /var/run/sendmail.pid` || exit 1 else /etc/rc.d/init.d/sendmail start || exit 1 fi exit $? EOF chmod 740 /etc/mail/configure # Bootscript install -v -m740 ${SCRDIR}/bootscripts/sendmail /etc/rc.d/init.d # script-name start stop bootscript_add_rc3 sendmail 65 25 cat > /usr/local/bin/mail-if-fail << "EOF" #!/bin/bash # This script is used to run a command. If the command failed, # an email is sent to the address specified by MAILTO. # Begin of user modifiable variables MAILFROM="${USER}@_DOMAIN_" MAILTO="root@_DOMAIN_" # End of User modifiable variables SENDMAIL="/usr/sbin/sendmail -t -r ${MAILFROM}" MAILFILE="/tmp/mail-if-fail-output$$" LOGFILE="/tmp/mail-if-fail-log$$" # Running the specified command ${*} 1> ${LOGFILE} 2>&1 ERROR_CODE=${?} if [ ${ERROR_CODE} -ne "0" ]; then echo "From: ${MAILFROM}" > ${MAILFILE} echo "To: ${MAILTO}" >> ${MAILFILE} echo "Subject: \"${1}\" FAILED (${ERROR_CODE})" >> ${MAILFILE} echo "Content-type: text/plain" >> ${MAILFILE} echo "Output of command ${*}:" >> ${MAILFILE} echo >> ${MAILFILE} cat ${LOGFILE} >> ${MAILFILE} cat ${MAILFILE} | ${SENDMAIL} || exit 1 rm -f ${MAILFILE} fi rm -f ${LOGFILE} exit ${ERROR_CODE} EOF sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /usr/local/bin/mail-if-fail chmod 755 /usr/local/bin/mail-if-fail cp ${SCRDIR}/misc/mail-files.sh /usr/local/bin chmod 755 /usr/local/bin/mail-files.sh # Executing configure script. /etc/mail/configure fi }