Script to Create Majordomo Lists

Creating a mailing list in Majordomo by hand is a tedious and error-prone process. This short bash script is designed to automate the process. It is specifically designed to work with Caldera OpenLinux 2.2, 2.3 and 24, but it can easily be adapted to work with other distributions which place the majordomo executables and configuration files in different places.

#!/bin/bash

# Script to automate creation of a Majordomo mailing list

if [ -z "$1" -o -z "$2" ] ; then
    echo "Usage: newlist listname list-owner"
    exit 1
fi

# Find the wrapper program

if [ -x /usr/lib/majordomo/wrapper ] ; then
    wrapper=/usr/lib/majordomo/wrapper
elif [ -x /usr/sbin/wrapper ] ; then
    wrapper=/usr/sbin/wrapper
fi

# Create the list file
touch /var/lib/majordomo/lists/$1
chown majordom. /var/lib/majordomo/lists/$1
chmod 664 /var/lib/majordomo/lists/$1

#Create the info file
cat >> /var/lib/majordomo/lists/$1.info << EOF
This is the information file for the $1 list.
The list has not been completely configured yet.
Please be patient.
EOF

chown majordom:majordom /var/lib/majordomo/lists/$1.info
chmod 664 /var/lib/majordomo/lists/$1.info

# Check for a "Majordomo-Owner" entry in /etc/aliases, and add it, if necessary

grep "[Mm]ajordomo-[Oo]wner" /etc/aliases
if [ $? -gt 0 ] ; then
    cat >> /etc/aliases << EOF

Majordomo-Owner: root@localhost
majordomo: "|$wrapper majordomo"

EOF
fi

# Append the list aliases to the /etc/aliases file
cat >> /etc/aliases << EOF

# Majordomo aliases automatically appended by newlist script
$1: "$wrapper resend -p bulk -l $1 $1-outgoing"
$1-owner: $2
owner-$1: $1-owner
$1-approval: $1-owner
$1-outgoing: :include:/var/lib/majordomo/lists/$1
$1-request: "|$wrapper majordomo -l $1"
owner-$1-request: $1-owner

EOF

newaliases

mail -s "List Config" majordomo@localhost << EOF
config $1 $1.admin
EOF

Page last updated: 23/Apr/2000 Back to Home Copyright © 1987-2010 Les Bell and Associates Pty Ltd. All rights reserved. webmaster@lesbell.com.au

...........................