#!/bin/bash # version 1.1 hn=$(hostname) # https://mail.loni.org/mailman/admin/LIST-NAME # place can be emac3, scusa0, hpc, lonimail # rsyncDest="rsync://isaac.lsu.edu/mailman-${hn}" rsyncDest="rsync://mail.si.hpc.lsu.edu" LISTS='/usr/lib/mailman/bin/list_lists' MEMBERS='/usr/lib/mailman/bin/list_members' CONFIG='/usr/lib/mailman/bin/config_list' VERIFY='/root/bin/verify-file-of-email-addresses.bash' PARENT='/tmp/mailinglists' dest="${PARENT}/${hn}" idx="${dest}/index.html" allSubscribers="${PARENT}/allBoth.txt" allEmails="${PARENT}/allUnsorted.txt" allEmailsS="${PARENT}/all.txt" users="${PARENT}/people.txt" usersHtml="${dest}/people.html" rm -rf ${PARENT} mkdir -p ${dest} echo "Generating html..." echo "" > ${idx} echo "" >> ${idx} echo "

Mailing List Reports for ${hn}

" >> ${idx} echo "
People and the mailing lists they are subscribed to
" >> ${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} - //") cfgName="${name}-config.html" cfg="${dest}/${cfgName}" admin="http://${hn}/mailman/admin/${name}" cnt=$(${MEMBERS} -f ${name} | sort -u | wc -l) echo "" >> ${idx} # now make html file of members of each list lst="${dest}/${name}.html" echo "" > ${lst} echo "" >> ${lst} echo "

${name} on ${hn}

" >> ${lst} echo "

" >> ${lst} echo "

List
Name
Member
addresses
Member
Count
Mailman
Admin
Text
Config
Decription
${name}${cnt}membersadminconfig${desc}
" >> ${idx} echo "
Page generated $(date)
" >> ${idx} echo "" >> ${idx} echo "" >> ${idx} # now make list by subscriber sort ${allSubscribers} > ${allSubscribers}.sort cat ${allSubscribers}.sort | awk -F'|' '{print $1}' | sort -u > ${users} echo "Generating html for people list..." echo "" > ${usersHtml} echo "" >> ${usersHtml} echo "

List of all subscribers and the lists they belong to

" >> ${usersHtml} echo "" >> ${usersHtml} echo "
" >> ${usersHtml} echo "
Page generated $(date)
" >> ${usersHtml} echo "" >> ${usersHtml} echo "" >> ${usersHtml} # now do email verification echo "now do email verification" ${MEMBERS} users | sort -u > ${PARENT}/users.txt logger "[mail_verification] USERS email verification started" ${VERIFY} users logger "[mail_verification] USERS email verification completed" sort -u ${allEmails} > ${allEmailsS} logger "[mail_verification] ALL email verification started" ${VERIFY} all logger "[mail_verification] ALL email verification completed" logger "[mail_verification] RSYNC email verification started" echo "Pushing html to server" rsync -avr -4 ${dest}/ ${rsyncDest}/mailman-${hn}/ rsync -avr -4 ${PARENT}/users/ ${rsyncDest}/mail_verification-${hn}/users/ rsync -avr -4 ${PARENT}/all/ ${rsyncDest}/mail_verification-${hn}/all/ logger "[mail_verification] RSYNC email verification completed" # rm -rf ${PARENT}