Dzahn has submitted this change and it was merged. Change subject: mailman: script to rename list ......................................................................
mailman: script to rename list This is a script that automates the instructions from: https://wikitech.wikimedia.org/wiki/Mailman#Rename_a_mailing_list Change-Id: I29e9e4dc0113698fe1c44b84c9bd618a20aee48d --- A modules/mailman/files/scripts/rename_list.sh M modules/mailman/manifests/scripts.pp 2 files changed, 86 insertions(+), 0 deletions(-) Approvals: jenkins-bot: Verified Dzahn: Looks good to me, approved diff --git a/modules/mailman/files/scripts/rename_list.sh b/modules/mailman/files/scripts/rename_list.sh new file mode 100755 index 0000000..b42af55 --- /dev/null +++ b/modules/mailman/files/scripts/rename_list.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# helper script to rename a mailman list +# Daniel Zahn <[email protected]> +# https://wikitech.wikimedia.org/wiki/Mailman#Rename_a_mailing_list +# +mailman_dir="/var/lib/mailman" + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "usage: $0 <old list> <new list>" + exit 0 +else + oldlist=$1 + newlist=$2 +fi + +echo "Going to rename list '$oldlist' to '$newlist'. Go ahead? (y/n)" +read yesorno +if [ $yesorno != 'y' ]; then + echo -e "Nothing has been done. Bye.\n" + exit 0 +fi + +# create new list $2 +echo -e "First we are creating the new list '${newlist} like any other list. \nPlease use your email address as list admin when asked. It will be overwritten later.'. \n" +echo -e "${mailman_dir}/bin/newlist ${newlist}\n\n" +${mailman_dir}/bin/newlist ${newlist} +sleep 1 + +# rsync ./lists/ dir (config, subscribers) from old to new +echo -e "Syncing list config and subscribers from '${oldlist}' to '${newlist}'.\n" +echo -e "/usr/bin/rsync -avp ${mailman_dir}/lists/${oldlist}/ ${mailman_dir}/lists/${newlist}/\n\n" +/usr/bin/rsync -avp ${mailman_dir}/lists/${oldlist}/ ${mailman_dir}/lists/${newlist}/ +sleep 1 + +# change "real_name" of the new list from old to new after we copied config +echo -e "Changing the list 'real_name' to '${newlist}' after we copied config over.\n" +echo -e "echo \"real_name = '${newlist}'\" | ${mailman_dir}/bin/config_list -i /dev/stdin ${newlist}\n\n" +echo "real_name = '${newlist}'" | ${mailman_dir}/bin/config_list -i /dev/stdin ${newlist} +sleep 1 + +# copy mbox file from old to new +echo -e "Copying mbox file from '${oldlist}' to '${newlist}'.\n" +echo -e "cp ${mailman_dir}/archives/private/${oldlist}.mbox/${oldlist}.mbox ${mailman_dir}/archives/private/${newlist}.mbox/${newlist}.mbox\n\n" +cp ${mailman_dir}/archives/private/${oldlist}.mbox/${oldlist}.mbox ${mailman_dir}/archives/private/${newlist}.mbox/${newlist}.mbox +sleep 1 + +# recreate archives from mbox for new list +echo -e "Recreating HTML archives from mbox file for '${newlist}'.\n" +echo -e "${mailman_dir}/bin/arch ${newlist}\n\n" +${mailman_dir}/bin/arch ${newlist} +sleep 1 + +# set correct permissions +echo -e "Making sure mbox file is owned by list:list.\n" +echo -e "chown list:list ${mailman_dir}/archives/private/${newlist}.mbox/${newlist}.mbox\n\n" +chown list:list ${mailman_dir}/archives/private/${newlist}.mbox/${newlist}.mbox +sleep 1 + +# add old list email address to "acceptable aliases" on new list +echo -e "Adding '${oldlist}@lists.wikimedia.org' to acceptable aliases on '${newlist}'.\n" +echo -e "echo \"acceptable_aliases = '${oldlist}@lists.wikimedia.org'\" | ${mailman_dir}/bin/config_list -i /dev/stdin ${newlist}\n\n" +echo "acceptable_aliases = '${oldlist}@lists.wikimedia.org'" | ${mailman_dir}/bin/config_list -i /dev/stdin ${newlist} +sleep 1 + +# output suggested apache redirect and exim alias lines +echo -e "\nPlease add the following code to './files/exim/listserver_aliases':\n--------\n" +echo -e "${oldlist}: ${newlist} \n--------\n" +sleep 1 + +echo -e "Please add the following code to './modules/mailman/templates/lists.wikimedia.org.org':\n--------\n" +echo -e "Redirect permanent /mailman/listinfo/${oldlist} https://<%= @lists_servername %>/mailm +an/listinfo/${newlist}\n--------\n\n" +sleep 1 + +echo -e "To finish this please upload the code changes above to Gerrit and merge.\n\nTest by sending a mail to both ${oldlist}@lists.wikimedia.org and ${newlist}@lists.wikimedia.org.\n\nCheck the listinfo pages at https://lists.wikimedia.org/mailman/listinfo/${oldlist} and https://lists.wikimedia.org/mailman/listinfo/${newlist}\n" +sleep 1 + +echo -e "Don't forget to update the ticket and that should be all. Bye.\n" + diff --git a/modules/mailman/manifests/scripts.pp b/modules/mailman/manifests/scripts.pp index b565e78..9c9f3c2 100644 --- a/modules/mailman/manifests/scripts.pp +++ b/modules/mailman/manifests/scripts.pp @@ -33,4 +33,11 @@ source => 'puppet:///modules/mailman/scripts/rsync_exim.sh' } + file { '/usr/local/sbin/rename_list': + ensure => 'present', + owner => 'root', + group => 'list', + mode => '0550', + source => 'puppet:///modules/mailman/scripts/rename_list.sh' + } } -- To view, visit https://gerrit.wikimedia.org/r/240024 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I29e9e4dc0113698fe1c44b84c9bd618a20aee48d Gerrit-PatchSet: 6 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dzahn <[email protected]> Gerrit-Reviewer: Dzahn <[email protected]> Gerrit-Reviewer: John F. Lewis <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
