#!/bin/sh # This script provides an example on how to extend the default archive # server with your own custom commands (for more info, look in the # .bin/arch_retrieve script). For this to work, you should put this # script in the .bin directory or the directory of a list itself. # Since this script is sourced, and not executed, environment changes # will be propagated back to the arch_retrieve script; also, you should # not "exit" from this script, since that will exit arch_retrieve as well. # $1 contains the command. # $* contains the command + arguments (already expanded inside the archive # directory). # $line contains the original unexpanded command line. # $maxfiles can be queried. # $ILLEGAL can be set to first illegal filename encountered. # $from contains the mail address of the sender. # $tmpfrom is the name of the transaction logfile. # $tmprequest is the name of the file containing the original mail. # If a command has been found, you have to use "set" to clear $1 afterward, # so as to notify the arch_retrieve script. # Here's an example of adding an "index" command that does the same # thing as "ls". In fact, the "ls" entry is just copied from # arch_retrieve here, and placed inside the case "$1" statement. # Also, a "set" command is included at the end. case "$1" in index|INDEX) shift # Prevent illegal pathnames case "$*" in *[/\ ]..[/\ ]*|..[/\ ]*|*[/\ ]..|..|[-/]*|*\ /*) $echo "$from ILLEGAL ls $line" >>$tmpfrom $test -z "$ILLEGAL" && ILLEGAL="$line";; *) # # Log the archive request # $touch tmp.lock $echo "$from ls $line" >>$tmpfrom ( $formail -rt -I"Subject: archive retrieval: ls $1" \ -i"From: $listreq" -A"X-Loop: $listaddr" \ -i"Reply-To: Please.write.a.new.mail.instead.of.replying@FIRST.WORD.archive" \ -i"Content-ID: <$line%$listreq>" \ -I"Precedence: bulk" <$tmprequest $test ! -z "$wrongaddress" && $echo "$wrongaddress" cd $archivedir # # Anything echo'd to stdout gets mailed back. # $echo "ls -l $line" $echo "BEGIN---------------cut here------------------" $ls -lL "$@" 2>&1 | $sed -e $breakoff_ls'a\ Truncating after '$breakoff_ls' names...' -e ${breakoff_ls}q $echo "END-----------------cut here------------------" ) | $SENDMAIL $sendmailOPT -t $sleep $waitsleep ;; esac ;; set ;; # And clear the command line to notify arch_retrieve esac