#!/bin/bash usage() { echo "Usage: $0 [-d] [year] " } if [ -z "$4" ] then usage exit 1 fi if ! which gearman > /dev/null 2> /dev/null then echo "gearman isn't installed on this machine. Please try another one." exit 1 fi if [ "x$1" = "x-d" ] then BACKGROUD= shift else BACKGROUD="-b" fi if [ "x${1:0:2}" = "x20" ] then YEAR=" $1" shift else YEAR= fi PROJECT_ID=$1 RENDU=$2 LOGIN=$3 if ! [ -f "$4" ] then usage exit 2 fi MIME=`file -b -i "$4" | cut -d ';' -f 1` if [ "$MIME" = "application/x-bzip2" ] then FILE=`bzip2 --decompress --stdout "$4" | gzip --stdout | base64` elif [ "$MIME" = "application/x-gzip" ] then FILE=`gzip --decompress --stdout "$4" | gzip --stdout | base64` elif [ "$MIME" = "application/x-xz" ] then FILE=`xz --decompress --stdout "$4" | gzip --stdout | base64` elif [ "$MIME" = "application/x-tar" ] then FILE=`tar cz "$4" | base64` elif [ "$MIME" = "inode/directory" ] then FILE=`tar xf "$4" | tar cz | base64` else echo "I don't know how to treat $4" >&2 exit 3 fi cat < std $YEAR $PROJECT_ID $RENDU $LOGIN rendu.tgz $FILE EOF