| 1 | # above should be a definition of EZPATH and the /bin/sh line |
| 2 | # automatically added at build time. |
| 3 | ######################################################################### |
| 4 | # Script to build ezmlm-request config file for the global interface |
| 5 | # Lists are presented in alphabetical order and digest lists are |
| 6 | # directly after the main list. Digest list info is only that |
| 7 | # they are digest of the main list. If the -n switch is used, |
| 8 | # the current number of subscribers is added to the info text. |
| 9 | # |
| 10 | # Usage: ezmlm-glconf [-n] dotdir [dotdir1 ...] > config |
| 11 | # where ``dotdir'' is the directory where the users .qmail files |
| 12 | # reside (usually ``~''), and ``config'' is the config file for |
| 13 | # ezmlm-request servicing the global interface. |
| 14 | # |
| 15 | # Note: This config file will provide info on all lists available |
| 16 | # and allow ``which'' for all lists. You may want to edit the |
| 17 | # output before using it. |
| 18 | ########################################################################## |
| 19 | |
| 20 | # Change if you change the name of the command |
| 21 | NAME='ezmlm-glconf' |
| 22 | |
| 23 | # Info text used for list-digest |
| 24 | DIGTXT='Digest of' |
| 25 | # ``subscribers'' for stating subscriber number |
| 26 | SUBTXT='subscribers' |
| 27 | # Info text if dir/text/info doesn't exist/is not readable |
| 28 | INFOTXT='No information available' |
| 29 | |
| 30 | # Set full path if you use the script as root or if the commands |
| 31 | # are not in your path. |
| 32 | HEAD='head' |
| 33 | TAIL='tail' |
| 34 | CAT='cat' |
| 35 | CUT='cut' |
| 36 | GREP='grep' |
| 37 | ECHO='echo' |
| 38 | LS='ls' |
| 39 | SORT='sort' |
| 40 | SED='sed' |
| 41 | WC='wc' |
| 42 | |
| 43 | # Nothing more to configure |
| 44 | ########################################################################## |
| 45 | |
| 46 | SUB='' |
| 47 | EZLIST="${EZPATH}/ezmlm-list" |
| 48 | FATAL="${NAME}: fatal: " |
| 49 | WARN="${NAME}: warning: " |
| 50 | USAGE="${NAME} [-n] dotdir [dotdir1 ...] > config" |
| 51 | |
| 52 | if [ "$1" = "-n" ]; then |
| 53 | shift |
| 54 | if [ ! -x "${EZLIST}" ]; then |
| 55 | echo "${WARN} ezmlm-list not found. Edit ezmlm binary path." |
| 56 | else |
| 57 | SUB='yes' |
| 58 | fi |
| 59 | fi |
| 60 | |
| 61 | if [ -z "$1" ]; then |
| 62 | ${ECHO} "$USAGE" |
| 63 | exit 100 |
| 64 | fi |
| 65 | |
| 66 | |
| 67 | ( |
| 68 | while [ -n "$1" ]; do |
| 69 | for i in `${LS} $1/.qmail-*-return-default` ; do |
| 70 | INFO='' |
| 71 | # get list directory |
| 72 | if [ -r "$i" ] ; then |
| 73 | DIR=`${TAIL} -1 "$i" | ${CUT} -d\' -f2` |
| 74 | # only dir that exists |
| 75 | if [ -d "$DIR" ] ; then |
| 76 | INFOFN="${DIR}/text/info" |
| 77 | if [ -r "${INFOFN}" ]; then |
| 78 | INFO=`${HEAD} -1 ${INFOFN}` |
| 79 | else |
| 80 | INFO="$INFOTXT" |
| 81 | ${ECHO} "$WARN No info for list in $DIR" 1>&2 |
| 82 | fi |
| 83 | |
| 84 | OUTLOCAL=`${CAT} $DIR/outlocal` |
| 85 | OUTHOST=`${CAT} $DIR/outhost` |
| 86 | if [ -z "$SUB" ]; then |
| 87 | SUBN='' |
| 88 | else |
| 89 | NO=`${EZLIST} ${DIR} | ${WC} -l |${SED} 's/ //g'` |
| 90 | SUBN=" (${NO} ${SUBTXT})" |
| 91 | fi |
| 92 | ${ECHO} "$i" | ${GREP} 'digest-return' >/dev/null && \ |
| 93 | { INFO="${DIGTXT} $OUTLOCAL@$OUTHOST."; \ |
| 94 | OUTLOCAL="${OUTLOCAL}~digest" ; } |
| 95 | ${ECHO} "$OUTLOCAL@$OUTHOST:$DIR:${INFO}${SUBN}" |
| 96 | else |
| 97 | ${ECHO} "$WARN $DIR not readable - list ignored" 1>&2 |
| 98 | fi |
| 99 | else |
| 100 | ${ECHO} "$WARN $i ignored: doesn't point to readable file" 1>&2 |
| 101 | fi |
| 102 | done ; |
| 103 | shift |
| 104 | done; |
| 105 | ) | ${SORT} | ${SED} 's/~digest@/-digest@/' |
| 106 | # list-digest after list |
| 107 | # "~"-cludge needed to get order right |