Great Circle Associates Majordomo-Users
(September 1996)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: MajorDomo 1.93 Shell scripts to create, delete lists
From: Major Domo List Server <majordom @ taex001 . tamu . edu>
Date: Wed, 18 Sep 1996 14:40:56 -0500 (CDT)
To: majordomo-users @ GreatCircle . COM

Here's what I genned up last year.  Works well for me. . .


# !/bin/sh
#
# NewList.sh Sep 27 1995 Paul M. Sittler (p-sittler@tamu.edu)
#            Dec 24, 25, 26, 29
#
# Usage: NewList.sh ExistingList NewList NewListOwner
#
# Written to make new MajorDomo v1.93 list setup easier when 
# lists are setup that are similar to existing lists.
#
# Customize for YOUR installation by editing the paths in the variables
#           "$Home, $Lists, $Archives, and $Digests"
#
##########################################################################
#
#  NewList.sh does the following tasks:
#
#   A) In the $Lists directory, copies all files from ExistingList 
#      to NewList files.  Files are also edited to reflect new list
#      names (using sed).
#
#   B) If $List/NewList.digest exists, creates the temporary digest 
#      directories in the $Digests/ directory for NewList.
#
#   C) If $List/NewList.digest exists, creates the archive and digest 
#      directories in the $Archives/ directory for NewList.
#
#   D) Edits "$Home/list-owner-info/list-owner-info.new-list" file to produce 
#      new   "$Home/list-owner-info/list-owner-info.NewList".
#
#      I keep these in a separate directory for my own convenience.
#
#   E) Mails "$Home/list-owner-info/list-owner-info.NewList" file to the
#      list-owner of NewList.
#
#   F) Edits aliases template file "$Home/aliases.new-list" to create
#                                  "$Home/aliases.NewList".
#
#      Mails "$Home/aliases.NewList" to root requesting activation.
#
#      The superuser may then simply insert "$Home/aliases.NewList" into 
#      "/etc/aliases" and run "newaliases" to activate NewList.
#
#   G) Adds line to "$Home/majordomo.cf" to establish archive
#      directory.  In my installation, this has a symbolic link from
#      "/etc/majordomo.cf".
#
#	@archive_dirs = ( "$filedir/4h-curr",
#	>>>>---->         "$filedir/new-list",
#	                  "$filedir/z-car" );
#
# This script depends upon MajorDomo's data files being set up 
# in three directories: "$Lists/", "$Digests/", and "$Archives/".
#
# Please edit the values for variables "Home, Lists, Archives, and Digests"
# to customize for YOUR MajorDomo installation.
#
#   $Lists/			Where ALL list admin files are kept.
#   $Lists/M-List			M-List subscribers
#   $Lists/M-List-digest		M-List-digest subscribers
#   $Lists/M-List-digest.config		M-List Digest configuration
#   $Lists/M-List-digest.info		M-List digest information
#   $Lists/M-List-digest.passwd		M-List digest password
#   $Lists/M-List.config		M-List configuration
#   $Lists/M-List.info			M-List information
#   $Lists/M-List.passwd		M-List password
#
#   $Archives/			Where ALL archive files are stored
#   $Archives/M-List/			Directory containing M-List Archives
#   $Archives/M-List/M-List.9511		M-List Archive files. . .
#   $Archives/M-List/M-List.9512		M-List Archive files. . .
#
#   $Archives/M-List-digest:	Where ALL digest files are stored
#   $Archives/M-List-digest/v9512.n146	M-List Digest files. . .
#   $Archives/M-List-digest/v9512.n147	M-List Digest files. . .
#
#   $Digests/			Where TMP digest files are stored
#   $Digests/M-List/			M-List TMP digest files. . .
#
#   Note: I have a set of new-list files in the lists directory that
#         I use as templates to set up a new list.
#
##########################################################################
#
# Important:  Edit variables for paths on YOUR installation.
#
Home=/tools/majordomo-1.93
Archives=/tools/majordomo-1.93/Lists/archive
Digests=/tools/majordomo-1.93/Lists/digest 
Lists=/tools/majordomo-1.93/Lists/lists

#
# Do some initial housekeeping.
#
# Check for proper number of arguments (3):  Abort with usage prompt.
#
  if [ $# -lt 3 ] || [ $# -ge 4 ]
  then
	echo "    Usage: `basename $0` ExistingList NewList NewListOwner."
	exit 1
  fi

#
# Check to see if ExistingList actually exists.  Abort if not.
#
  if [ ! -f $Lists/$1 ]
  then
	echo "MajorDomo list $1 not found."
	echo "Thus, $1 cannot be used as a template."
	echo "    Usage: `basename $0` ExistingList NewList NewListOwner."
	exit 1
  fi

#
# Check to see if NewList already exists.  Abort if so.
#
  if [ -f $Lists/$2 ]
  then
	echo "MajorDomo list $Lists/$2 already exists."
	echo "Creating it again would clobber it."
	echo "    Usage: `basename $0` ExistingList NewList NewListOwner."
	exit 1
  fi

#
# Change to the MajorDomo Lists directory.
#
  echo "Changing:  Directory to $Lists."
  cd $Lists

#
# A) Copies every file named ExistingListAnything to NewListAnything.
#
  for File in $1*
  do
	echo "Copying:   $File to $2${File##$1}.tmp."
	cp               $File    $2${File##$1}.tmp
	echo "Editing:   $2${File##$1}.tmp changing $1 to $2."
	sed "s/$1/$2/g"  $2${File##$1}.tmp >  $2${File##$1}
	echo "Removing:  $2${File##$1}.tmp file."
	rm               $2${File##$1}.tmp
  done
  echo $3        >  $Lists/$2
  echo $3        >  $Lists/$2-digest
  echo PassWord  >  $Lists/$2.passwd
  echo PassWord  >  $Lists/$2-digest.passwd

#
# Change back to the MajorDomo home directory.
#
  echo "Changing:  Directory to MajorDomo $Home directory."
  cd $Home

#
# B, C) Set up $Archives/digest directories (if needed).
#
  if [ -f $Lists/$2-digest ] ; then
	echo "Making:    Archive directories."
	mkdir $Archives/$2
  	mkdir $Archives/$2-digest
	# Setup digest directory for digest TMP files (if needed).
  	echo "Making:    Digest directory for digest TMP files."
  	mkdir $Digests/$2-digest
  fi

#
# D) Editing $Home/list-owner-info/list-owner-info.new-list 
#         to $Home/list-owner-info/list-owner-info.$2.
#
  echo "Editing:   $Home/list-owner-info/list-owner-info.new-list $2."
  sed "s/new-list/$2/g" \
       < $Home/list-owner-info/list-owner-info.new-list \
       > $Home/list-owner-info/list-owner-info.$2

#
# E) Mail list-owner-info.new-list to the list-owner.
#
  echo "Mailing:   list-owner-info.$2 to the list-owner."
  cat $Home/list-owner-info/list-owner-info.$2 | \
      mail -s "$2 List Owner Information"    \
      $3

#
# F) Editing Aliases template file "$Home/aliases.new-list" 
#                        to create "$Home/aliases.NewList".
#
  echo "Editing:   $Home/aliases.new-list to create $Home/aliases.$2."
  sed "s/new-list/$2/g"     < $Home/aliases.new-list > $Home/aliases.tmp
  sed "s/NewListOwner/$3/g" < $Home/aliases.tmp      > $Home/aliases.$2 ; rm $Home/aliases.tmp

#
# Mailing list-owner-info.new-list to the list-owner.
#
  echo "Mailing:   $Home/aliases.$2 to the SuperUser."
  cat $Home/aliases.$2 | \
      mail -s "Please add $2 aliases file and run newaliases." \
      root

#
# G) Adds line to "$Home/majordomo.cf" to establish archive
#    directory.  In my installation this is linked to 
#    "/etc/majordomo.cf".
#
#	@archive_dirs = ( "$filedir/4h-curr",
#	>>>>---->         "$filedir/new-list",
#	                  "$filedir/z-car" );
#
  cp $Home/majordomo.cf $Home/majordomo.cf.old  
  sed '/@archive_dirs = (/a\
	\"$filedir/new-list\", \
' < $Home/majordomo.cf.old | sed "s/new-list/$2/" > $Home/majordomo.cf

#
##########################################################################
#
  echo "    That's all, folks. . ."
#
##########################################################################

==========================================================================

# !/bin/sh
#
# DelList.sh Sep 27 1995 Paul M. Sittler (p-sittler@tamu.edu)
#            Dec 24, 25, 26
#
# Usage: DelList.sh ExistingList
#
# Written to make new MajorDomo v1.93 list deletion easier.
# Written/tested using BASH, but should work with other shells.
#
# Customize for YOUR installation by editing the paths in the variables
#           "$Home, $Lists, $Archives, and $Digests"
#
##########################################################################
#
#  DelList.sh does the following tasks:
#
#   A) In the $Lists/ directory, deletes all ExistingList files.
#
#   B) Removes the archive and digest directories in the
#      $Archives/ directory for ExistingList.
#
#   C) Removes the temporary digest directories in the 
#      $Digests/ directory for ExistingList.
#
#   D) Mails "$Home/aliases.ExistingList" to root requesting deletion.
#
#      The superuser may then simply delete the "ExistingList" section
#      from /etc/aliases and run "newaliases" to delete ExistingList.
#
#   E) Deletes "$Home/list-owner-info/list-owner-info.ExistingList" file.
#
#      I keep these in a separate directory for my own convenience.
#
#   F) Deletes line in "$Home/majordomo.cf" that established archive
#      directory.
#
#	@archive_dirs = ( "$filedir/4h-curr",
#	>>>>---->         "$filedir/ExistingList",
#	                  "$filedir/z-car" );
#
# This script depends upon MajorDomo's data files being set up 
# in three directories: "$Lists/", "$Digests/", and "$Archives/".
#
# Please edit the values for variables "Home, Lists, Archives, and Digests"
# to customize for YOUR MajorDomo installation.
#
#   $Lists/			Where ALL list admin files are kept.
#   $Lists/M-List			M-List subscribers
#   $Lists/M-List-digest		M-List-digest subscribers
#   $Lists/M-List-digest.config		M-List Digest configuration
#   $Lists/M-List-digest.info		M-List digest information
#   $Lists/M-List-digest.passwd		M-List digest password
#   $Lists/M-List.config		M-List configuration
#   $Lists/M-List.info			M-List information
#   $Lists/M-List.passwd		M-List password
#
#   $Archives/			Where ALL archive files are stored
#   $Archives/M-List/			Directory containing M-List Archives
#   $Archives/M-List/M-List.9511		M-List Archive files. . .
#   $Archives/M-List/M-List.9512		M-List Archive files. . .
#
#   $Archives/M-List-digest:	Where ALL digest files are stored
#   $Archives/M-List-digest/v9512.n146	M-List Digest files. . .
#   $Archives/M-List-digest/v9512.n147	M-List Digest files. . .
#
#   $Digests/			Where TMP digest files are stored
#   $Digests/M-List/			M-List TMP digest files. . .
#
##########################################################################
#
# Important:  Edit variables for paths on YOUR installation.
#
  Home=/tools/majordomo-1.93
  Archives=/tools/majordomo-1.93/Lists/archive
  Digests=/tools/majordomo-1.93/Lists/digest 
  Lists=/tools/majordomo-1.93/Lists/lists

#
# Do some initial housekeeping.
#
# Check for proper number of arguments (1):  Abort with usage prompt.
#
  if [ $# -lt 1 ] || [ $# -ge 2 ]
  then
	echo "    Usage: `basename $0` ExistingList"
	exit 1
  fi

#
# Check to see if ExistingList actually exists.  Abort if not.
#
  if [ ! -f $Lists/$1 ]
  then
	echo "MajorDomo list $Lists/$1 not found."
	echo "Thus, $Lists/$1 cannot be deleted."
	echo "    Usage: `basename $0` ExistingList"
	exit 1
  fi

#
# A) Deletes every file named ExistingListAnything.
#
  for File in $Lists/$1*
  do
	echo "Deleting:  $File"
	rm $File
  done

#
# B) Delete $Archives/digest directories (if needed).
#
  if [ -d $Archives/$1 ] 
  then
	echo "Deleting:  $Archive/$1 directories."
	rm -r $Archives/$1
  	rm -r $Archives/$1-digest
  fi

#
# C) Delete digest directory for digest TMP files (if needed).
#
  if [ -d $Digests/$1-digest ]
  then
  	echo "Deleting:  $Digests/$1-digest/ directory for digest TMP files."
  	rm -r $Digests/$1-digest
  fi

#
# D) Mail $Home/aliases.ExistingList to the SuperUser requesting deletion.
#
  echo "Mailing:   $Home/aliases.$1 to the SuperUser."
  cat  $Home/aliases.$1 | \
      mail -s "Please delete $1 from aliases file and run newaliases." \
      root

#
# E) Deletes "$Home/list-owner-info/list-owner-info.ExistingList" file.
#
  echo "Deleting:  $Home/list-owner-info/list-owner-info.$1."
  rm $Home/list-owner-info/list-owner-info.$1

#
# F) Delete line from "$Home/majordomo.cf" that established archive
#    directory.  In my installation this is linked to "/etc/majordomo.cf".
#
#	@archive_dirs = ( "$filedir/4h-curr",
#	>>>>---->         "$filedir/ExistingList",
#	                  "$filedir/z-car" );
#
  cp $Home/majordomo.cf $Home/majordomo.cf.old  
  sed "/\"\$filedir\/$1\",/d"  \
      < $Home/majordomo.cf.old \
      > $Home/majordomo.cf

#
##########################################################################
#
  echo "    That's all, folks. . ."
#
##########################################################################


-------
Paul M. Sittler (MajorDomo)  |   / /  (_)__  __ ____  __ | The choice
TAEX001 System Administrator |  / /__/ / _ \/ // /\ \/ / |  of a GNU
email: p-sittler@tamu.edu    | /____/_/_//_/\_,_/ /_/\_\ | Generation
                               A 386 is a terrible thing to waste...



Indexed By Date Previous: Re: Merging 2 liststs
From: Richard Pieri <ratinox@unilab.dfci.harvard.edu>
Next: Re: too bad resend isn't stand-alone anymore
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Indexed By Thread Previous: Re: moderated list, no subject, hmmm
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Next: Swapspace filled up by Majordomo
From: th@hermes.ccn.net (Tassilo Hofmann)

Google
 
Search Internet Search www.greatcircle.com