#!/bin/ksh # $Id$ # Written by Jens Elkner (elkner@cs.uni-magdeburg.de) # License: free as beer BASEDIR=@CLIENT_BASEDIR@/majordomo Usage() { print -u2 " Usage: $0 [-l lang] [-o owner] [-a password] [-p password] listname@domain Creates all required config files for the given list using the templates from ${BASEDIR}/lists/example.com/ All list specific files are overwritten without any notice! Options: -l lang .. language to use. Currently 'en' and 'de' are supported, only -o owner .. alias or user to set as list owner (e.g. 'root,postmaster') -p password .. approval password for the list -a password .. admin password for the list " } ME=`id` ME=${ME%%\)*} ME=${ME#*\(} if [ "$ME" != "majordomo" ]; then print -u2 "This script must be run by user \"majordomo\" - exiting" exit 4 fi LANG="en" DOMAIN="" LISTNAME="" ADM_PASS="" APPROVAL_PASS="" [ -d /usr/xpg4/bin ] && PATH=/usr/xpg4/bin:$PATH while getopts "a:l:o:p:" option ; do case "$option" in "l") if [ "$OPTARG" = "en" -o "$OPTARG" = "de" ]; then LANG="$OPTARG" else print -u2 "Unsupported language \"$OPTARG\" - exiting" exit 1 fi ;; "o") OWNER="$OPTARG" ;; "a") ADM_PASS="${OPTARG}" ;; "p") APPROVAL_PASS="${OPTARG}" ;; esac done X=$((OPTIND-1)) shift $X if [ -z "$1" ]; then Usage exit 2 fi DOMAIN="$1" DOMAIN=${DOMAIN#*@} LISTNAME="$1" LISTNAME=${LISTNAME%@*} if [ -z "$DOMAIN" -o -z "$LISTNAME" ]; then print -u2 "Invalid mailinglist address - exiting" exit 3 fi [ "$LANG" = "" ] && LANG="en" umask 022 if [ ! -d ${BASEDIR}/lists/${DOMAIN} ]; then mkdir -p "${BASEDIR}/lists/${DOMAIN}" mkdir -p "${BASEDIR}/archive/${DOMAIN}" [ -r "${BASEDIR}/log" ] || mkdir "${BASEDIR}/log" touch "${BASEDIR}/log/${DOMAIN}" DATE=`/usr/bin/date` for f in site.aliases site.cf site.virtuser ; do sed -e "s|example\.com|${DOMAIN}|g" \ -e "s|@something_else@|$DATE|" \ ${BASEDIR}/lists/example.com/$f \ >"${BASEDIR}/lists/${DOMAIN}/$f" done echo " Execute the following commands as super user, if not already done: cat ${BASEDIR}/lists/${DOMAIN}/site.aliases \\ >> /etc/mail/aliases cat ${BASEDIR}/lists/${DOMAIN}/site.virtuser \\ >> /etc/mail/virtusertable " fi touch "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}" mkdir -p "${BASEDIR}/archive/${DOMAIN}/${LISTNAME}" for f in aliases config info intro virtuser ; do if [ -f ${BASEDIR}/lists/example.com/testlist.${f}.$LANG ]; then TEMPLATE="${BASEDIR}/lists/example.com/testlist.${f}.$LANG" else TEMPLATE="${BASEDIR}/lists/example.com/testlist.${f}" fi sed -e "s|example.com|${DOMAIN}|g" \ -e "s|testlist|${LISTNAME}|g" \ -e "s|/wrapper majordomo|/wrapper majordomo.$LANG|" \ $TEMPLATE >"${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.$f" done TMPF=`mktemp /tmp/majordomo.XXXXXXXX` if [ -z "$TMPF" ]; then print -u2 "Unable to create tmeporary file list passwords and owner cannot be adjusted!" else if [ -n "$ADM_PASS" ]; then sed -e "/^admin_passwd/ s|=.*|= ${ADM_PASS}|" \ "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.config" >$TMPF cp $TMPF "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.config" fi if [ -n "$APPROVAL_PASS" ]; then sed -e "/^approve_passwd/ s|=.*|= ${APPROVAL_PASS}|" \ "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.config" >$TMPF cp $TMPF "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.config" fi if [ -n "$OWNER" ]; then sed -e "s|:[[:space:]]*root|: $OWNER|" \ "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.aliases" >$TMPF cp $TMPF "${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.aliases" fi rm -f $TMPF fi echo " Now adjust the following files in ${BASEDIR}/lists/${DOMAIN}/: ${LISTNAME}.config ${LISTNAME}.info ${LISTNAME}.intro and optionally ${LISTNAME}.aliases and execute the following commands as super user: cat ${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.aliases \\ >> /etc/mail/aliases cat ${BASEDIR}/lists/${DOMAIN}/${LISTNAME}.virtuser \\ >> /etc/mail/virtusertable Finally you need to make the changes avaliable to sendmail by executing the follwoing commands: /usr/bin/newaliases makedbm /etc/mail/virtusertable /etc/mail/virtusertable makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable depending on the DB format used for virtusertable. "