#!/bin/bash
place=$(hostname | awk -F'.' '{print $1}')
# place can be emac3, scusa0, hpc, lonimail
rsyncDest="rsync://isaac.lsu.edu/mailman-${place}"
LISTS='/usr/lib/mailman/bin/list_lists'
MEMBERS='/usr/lib/mailman/bin/list_members'
PARENT='/tmp/html'
dest="${PARENT}/${place}"
idx="${dest}/index.html"
rm -rf ${PARENT}
mkdir -p ${dest}
echo "Generating html..."
echo "" > ${idx}
echo "
" >> ${idx}
echo "" >> ${idx}
${LISTS} | grep -v 'matching mailing lists found' | sort -u | while read line
do
echo " Processing: ${line}"
name=$(echo ${line} | awk '{print $1}')
desc=$(echo ${line} | sed "s/^${name} - //")
echo " - ${name} - ${desc}
" >> ${idx}
# now make html file of members of each list
lst="${dest}/${name}.html"
echo "" > ${lst}
echo "" >> ${lst}
echo "${name}
" >> ${lst}
echo "" >> ${lst}
echo "
" >> ${lst}
${MEMBERS} -f ${name} | sort -u | while read line
do
email=$(echo ${line} | sed 's/(/' | sed 's/>/)/')
echo "- ${email}
" >> ${lst}
done
echo "" >> ${lst}
echo "" >> ${lst}
done
echo "
" >> ${idx}
echo "" >> ${idx}
echo "" >> ${idx}
echo "Pushing html to server: rsync -avr ${dest}/ ${rsyncDest}/"
rsync -avr ${dest}/ ${rsyncDest}/