#!/bin/sh # Sets up the ourschool mailing lists. Part of a two-piece process. # /home/school/sites/projects/ourschool/scripts/listgen.py uses the Django ORM # to extract subscribers from profile collections. # This script takes those text files and runs them through Mailman CLI scripts to do the actual subscribing. # Each run is a clean sweep - dumps all list members first, then re-adds. ########################## # NOTES # Mailman $mm_path/add_members flags # -w y/n = Do not send welcome message # -e y/n = Set users to receive mail/nomail # -r filename - get list from filename # Path to mailman binaries mm_path="/usr/local/cpanel/3rdparty/mailman/bin" LISTS=( kindergarten first second third twothree fourth fifth fourfive board teachers alumni executivecom participation everyone ) NUMLISTS=${#LISTS[@]} x=0 while [ "$x" != $NUMLISTS ] # Step through lists, feeding each (drop everyone, then re-add from text files) do echo THISLIST="${LISTS[$x]}" # Calculate name of current list ml="${THISLIST}_ourschool.org" echo $ml textpath="/home/school/sites/projects/ourschool/scripts/listgen/${THISLIST}.txt" nomailtextpath="/home/school/sites/projects/ourschool/scripts/listgen/${THISLIST}-nomail.txt" echo $textpath if [ -f "$nomailtextpath" ] then echo $nomailtextpath fi # Do it $mm_path/remove_members -a -n $ml $mm_path/add_members -w n -r $textpath $ml if [ -f "$nomailtextpath" ] # Subscribe -nomail users for this list in nomail mode then $mm_path/add_members -w n -e n -r $nomailtextpath $ml fi let x+=1 done