Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e253a23c09
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 83 lines (71 sloc) 1.74 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/sh
#
# Send multiples files and/or directories as a tar/compressed
# image, in a MIME message.
#

DELAY=0
FROM=

# compression method (none, gzip or compress)
METHOD=none
# compression filter
COMPRESS=cat
# uncompression filter
UNCOMPRESS=cat
# compression description to append to content-type
CONVERSION=

# default compression method based on installed software
# prefer compress over gzip for backward compatibility
if command -v compress >/dev/null 2>&1 ; then
    METHOD=compress
elif command -v gzip >/dev/null 2>&1 ; then
    METHOD=gzip
fi

# handle command-line options to override compression method and delay
while [ $# -gt 3 ]; do
    case "$1" in
        -gzip) METHOD=gzip
shift
;;
-compress) METHOD=compress
shift
;;
        -none) METHOD=none
shift
;;
-*) DELAY="`echo $1 | sed -e 's%-%%'`"
shift
;;
*) break
;;
    esac
done

# set variables based on chosen compression method
if [ $METHOD = compress ]; then
    COMPRESS=compress
    UNCOMPRESS=uncompress
    CONVERSION="; x-conversions=compress"
elif [ $METHOD = gzip ]; then
    COMPRESS="gzip -c"
    UNCOMPRESS="gzip -dc"
    CONVERSION="; x-conversions=gzip"
fi

if [ ! -z "$PERSON" ]; then
    FROM="-from $PERSON"
fi

if [ $# -lt 3 ]; then
    echo 'usage: sendfiles: "mailpath" "subject-string" directory-or-file ...' 1>&2
    exit 1;
fi

mailpath="$1"
echo "mailpath = $mailpath" 1>&2
shift

subject="$1"
echo "subject-string = $subject" 1>&2
shift

echo "files = $*" 1>&2

tar cvf - "$@" | $COMPRESS | \
    %libdir%/viamail -to "$mailpath" -subject "$subject" \
-parameters "type=tar$CONVERSION" \
-comment "extract with $UNCOMPRESS | tar xvpf -" \
-delay "$DELAY" \
-verbose $FROM
Something went wrong with that request. Please try again.