1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #!/bin/sh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- basedir=/var/spool/maildirs
-
-
- trashbase=/var/spool/deleted-maildirs
-
-
- if [ ! -e "$trashbase" ]; then
- echo "trashbase '$trashbase' does not exist; bailing out."
- exit 1
- fi
-
- if [ `echo $1 | fgrep '..'` ]; then
- echo "First argument contained a double-dot sequence; bailing out."
- exit 1
- fi
- if [ `echo $2 | fgrep '..'` ]; then
- echo "First argument contained a double-dot sequence; bailing out."
- exit 1
- fi
-
- subdir=`echo "$1" | sed 's/@.*//'`
-
- maildir="${basedir}/$2/${subdir}"
- trashdir="${trashbase}/$2/`date +%F_%T`_${subdir}"
-
- parent=`dirname "$trashdir"`
- if [ ! -d "$parent" ]; then
- if [ -e "$parent" ]; then
- echo "Strainge - directory '$parent' exists, but is not a directory."
- echo "Bailing out."
- exit 1
- else
- mkdir -p "$parent"
- if [ $? -ne 0 ]; then
- echo "mkdir -p '$parent' returned non-zero; bailing out."
- exit 1
- fi
- fi
- fi
-
- if [ ! -e "$maildir" ]; then
- echo "maildir '$maildir' does not exist; nothing to do."
- exit 1
- fi
- if [ -e "$trashdir" ]; then
- echo "trashdir '$trashdir' already exists; bailing out."
- exit 1
- fi
-
- mv $maildir $trashdir
-
- exit $?
|