27 lines
554 B
Bash
Executable file
27 lines
554 B
Bash
Executable file
#!/bin/bash
|
|
|
|
function err {
|
|
echo "$*" | mail -s "archiver: mail archiving failed" root
|
|
exit 1
|
|
}
|
|
|
|
_group=$1
|
|
_list=$2
|
|
|
|
if [ -z "$_group" ] || [ -z "$_list" ]; then
|
|
echo "Usage: $(basename "$0") <group> <list>"
|
|
exit 1
|
|
fi
|
|
|
|
_dir="/roles/${_group}/library/archive/${_list}"
|
|
_mbox="${_dir}/$(date +%Y-%m)"
|
|
|
|
if [ ! -d "$_dir" ]; then
|
|
if ! mkdir -p "$_dir" ; then
|
|
err "ERROR: Failed to create archive directory '${_dir}'"
|
|
fi
|
|
fi
|
|
|
|
if ! "/usr/bin/spamc" >> "${_mbox}" ; then
|
|
err "ERROR: Failed to archive mail into '${_mbox}'"
|
|
fi
|