Blame | Last modification | View Log | RSS feed
#!/bin/sh# Generate db and cf files if necessary. This used to be handled by# /etc/mail/Makefile.teste() {if ! test -e "$1"; thenecho "$1 doesn't exist"exit 2fi}makedb() {teste "${1%.db}"if [ -z "$SM_FORCE_DBREBUILD" ]; thentest "${1%.db}" -nt "$1" || return 0fiif [ "$1" = userdb.db ]; thenmakemap btree "$1" < "${1%.db}"elsemakemap hash "$1" < "${1%.db}"fi}makealiasesdb() {uptodate=1if [ -z "$SM_FORCE_DBREBUILD" ]; thenfiles=$(grep '^O AliasFile=' sendmail.cf |while read a; do echo ${a#*=}; done)for a in $files; doif [ "$a" = /etc/aliases ]; then# /etc/aliases.db may be used by other MTA, make sure nothing# has touched it since our last newaliases calltest "$a" -nt "${a}.db" ||test aliasesdb-stamp -nt "${a}.db" ||test aliasesdb-stamp -ot "${a}.db" || continueelsetest "$a" -nt "${a}.db" || continuefiuptodate=0breakdoneelseuptodate=0fi[ $uptodate = 1 ] && return 0# check if alternatives is configured to sendmailif [ "$(readlink -e /usr/bin/newaliases)" = /usr/sbin/sendmail.sendmail ]then/usr/bin/newaliases > /dev/nulltouch -r /etc/aliases.db aliasesdb-stamp 2> /dev/nullelserm -f aliasesdb-stampfi}makecf() {mc=${1%.cf}.mcteste "$mc"if [ -z "$SM_FORCE_CFREBUILD" ]; thentest "$mc" -nt "$1" || return 0fiif test -f /usr/share/sendmail-cf/m4/cf.m4; thenumask 022[ -e "$1" ] && mv -f "$1" "$1".bakm4 "$mc" > "$1"elseecho "WARNING: '$mc' is modified. Please install package sendmail-cf to update your configuration."exit 15fi}makeall() {# These could be used by sendmail, but are not part of the default install.# To use them you will have to generate your own sendmail.cf with# FEATURE('whatever')test -f bitdomain && makedb bitdomain.dbtest -f uudomain && makedb uudomain.dbtest -f genericstable && makedb genericstable.dbtest -f userdb && makedb userdb.dbtest -f authinfo && makedb authinfo.dbmakedb virtusertable.dbmakedb access.dbmakedb domaintable.dbmakedb mailertable.dbmakecf sendmail.cfmakecf submit.cf}cd /etc/mail || exit 1[ $# -eq 0 ] && makeallfor target; docase "$target" in*.db)makedb "$target";;*.cf)makecf "$target";;all)makeall;;aliases)makealiasesdb;;clean)rm -f *.db *~ aliasesdb-stamp;;start|stop|restart)service sendmail "$target";;*)echo "Don't know how to make $target"exit 2esacdone