Skip to content

Instantly share code, notes, and snippets.

@ferthalangur
Last active March 10, 2016 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferthalangur/c66dd4258e848134f04e to your computer and use it in GitHub Desktop.
Save ferthalangur/c66dd4258e848134f04e to your computer and use it in GitHub Desktop.
List members of all Mailman lists on a remote server
#!/bin/bash
#############################################################
# list_mailman_list_members
#
# Bash script to log in to a server running Mailman
# software and generate a list of members of each list.
#
# Configurable Parameters:
#
# SERVER: Hostname, FQDN or alias in your SSH config for the server
#
# USER: Which user to log in as on that server. You must be able to SSH
# in with this user, preferably without a password (key authentication)
#
# USESUDO: Uncomment if you that user needs sudo for the mailman commands
#
# MM_PATH: Where to find Mailman commands on the remote server. Debian/Ubuntu
# package installer puts them in /usr/sbin/ but installing from source
# and not changing default $prefix puts them in /usr/local/mailman/bin/.
# you can blank or comment out the line if you are sure it is in the default
# $PATH.
#
# Todo:
# - Error checking
# - Nicer report options?
#
#############################################################################
#
# Author: Rob Jenson - https://github.com/ferthalangur
#
# Copyright 2016 : Spotch Systems Consulting : https://www.spotch.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#############################################################################
# Where the mailing lists are
SERVER="mailman.example.org"
# Which user to log in as.
USER="ubuntu"
# Uncomment if you want to use sudo.
#USESUDO="sudo"
# Where Mailman is installed on $SERVER.
MM_PATH="/usr/local/mailman/bin/"
#
# No User-Serviceable Parts Below Here
#
echo "# List of Mailman list members on ${SERVER} #"
echo ""
lists=`ssh ${USER}@${SERVER} ${USESUDO} ${MM_PATH}list_lists -b`
for list in ${lists}
do
echo "## Members of ${list} on ${SERVER}: ##"
echo ""
ssh ${USER}@${SERVER} ${USESUDO} ${MM_PATH}list_members ${list}
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment