#!/bin/bash ######################################################################## # Copyright (C) 2015 Max Mehl ######################################################################## # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ######################################################################## # # Interactive script to manage the most used functions of ezmlm-idx. # Tested on an uberspace.de account. # ######################################################################## if [ -z "$1" -o "$1" = "--help" ]; then echo "Usage: $0 <.qmail file of list> " exit 1 fi LISTNAME=$1 LISTDIR=$2 LISTQMAIL=$3 LISTDOM=$4 echo "> Name of list: $LISTNAME" echo "> Directory of list: $LISTDIR" echo "> .qmail file of list: $LISTQMAIL" echo "> Domain of list: $LISTDOM" echo "Correct? Enter to continue, Ctrl+C to quit" read END helptext() { echo "Available options:" echo " +-------------------------------------+" echo " | h - Print this help |" echo " | q - Quit |" echo " | e - Edit ezmlm options |" echo " | s - Add subscriber |" echo " | S - Delete subscriber |" echo " | l - List all subscribers/mods/owner |" echo " | o - List/Set owner |" echo " | m - Add moderator |" echo " | c - Create ezmlm list |" echo " | d - Delete ezmlm list |" echo "+--------------------------------------+" } helptext while : do #tput clear # Schirm loeschen und Menuetext ausgeben echo -n "What to do? h for help: " read INPUT case $INPUT in h) helptext echo "";; q) echo "Bye!" && exit 1 echo "";; e) read -p "Please type the desired parameters and arguments. man ezmlm-make for full list of options: " PARS ezmlm-make -+ $PARS $LISTDIR $LISTQMAIL $LISTNAME $LISTDOM unset PARS echo "";; s) read -p "Email-address(es) of subscriber(s) to add (if multiple addresses, use space to separate): " SUBMAIL ezmlm-sub $LISTDIR $SUBMAIL echo "Added $SUBMAIL to $LISTNAME" unset SUBMAIL echo "";; S) read -p "Email-address(es) of subscriber(s) to delete (if multiple addresses, use space to separate): " SUBMAIL ezmlm-unsub $LISTDIR $SUBMAIL echo "Unsubscribed $SUBMAIL from $LISTNAME" unset SUBMAIL echo "";; l) echo "All subscribers:" && ezmlm-list $LISTDIR && echo "" echo "All moderators (ignore T in front of address):" && cat $LISTDIR/mod/subscribers/* && echo -e "\n" echo "Owner:" && cat $LISTDIR/owner echo "";; o) echo "The current owner is: " && cat $LISTDIR/owner read -p "Would you change the list's owner? [y/n]: " YN if [ "$YN" = "y" ]; then read -p "Insert the new owner's email address: " OWNER ezmlm-make -+ -5 $OWNER $LISTDIR $LISTQMAIL $LISTNAME $LISTDOM echo "$OWNER is the new owner of $LISTNAME" else echo "Owner not changed." fi unset YN OWNER echo "";; m) read -p "Insert the new moderator's address: " MOD ezmlm-sub $LISTDIR mod $MOD echo "$MOD is now a moderator of $LISTNAME" unset MOD echo "";; c) echo "The list will be created with following options you gave with the start of the script:" echo "> Name of list: $LISTNAME" echo "> Directory of list: $LISTDIR" echo "> .qmail file of list: $LISTQMAIL" echo "> Domain of list: $LISTDOM" read -p "Are they correct? Type any key to continue, type n to change them separately." YN if [ "$YN" = "n" ]; then read -p "> Name of list: " LISTNAME read -p "> Directory of list: " LISTDIR read -p "> .qmail file of list: " LISTQMAIL read -p "> Domain of list: " LISTDOM else echo "Options not changed." fi PARS="-s -u -f -C /etc/ezmlm/de" echo "Following parameters will be used for list's creation: $PARS" read -p "Should they be used? Type any key to continue, type n to change them. man ezmlm-make for all options: " YN if [ "$YN" = "n" ]; then read -p "Insert the disired parameters: " PARS echo "New parameters for list's creation are: $PARS" else echo "Parameters not changed." fi ezmlm-make $PARS $LISTDIR $LISTQMAIL $LISTNAME $LISTDOM echo "$LISTNAME has been successfully created." unset YN PARS echo "";; d) read -p "Should the list $LISTNAME really be deleted? .qmail files and the whole directory will be lost after this action! Type y to delete the list." YN if [ "$YN" = y ]; then rm $LISTQMAIL rm $LISTQMAIL-* rm -rf $LISTDIR else echo "Nothing has been deleted." fi unset YN echo "";; *) echo "Wrong input. Try again!" echo "";; esac done