Added sender-option.

This commit is contained in:
Oliver Rümpelein 2015-01-02 12:51:52 +01:00
parent 4151b599a4
commit 42e27220a6

View file

@ -5,13 +5,15 @@ PIZZAHOST=$(hostname -f)
PIZZAUSER=$(whoami) PIZZAUSER=$(whoami)
PIZZAART= PIZZAART=
PIZZARCV= PIZZARCV=
PIZZASEND=
help() { help() {
echo "pizza - sent small ASCII-Icons by Mail" echo "pizza - sent small ASCII-Icons by Mail"
echo "--------------------------------------" echo "--------------------------------------"
echo "Usage: -p Sent a pizza (default)" echo "Usage: -p Sent a pizza (default)"
echo " -l Sent a heart" echo " -l Sent a heart"
echo " -m <addr> Receivers address non-optional)" echo " -m <addr> Receivers address (non-optional)"
echo " -s <addr> Senders address, defaults to user@host"
echo " -h Print this help-message" echo " -h Print this help-message"
} }
@ -21,7 +23,7 @@ if [ ! $1 ]; then
exit 1 exit 1
fi fi
while getopts "plhm:" opt; do while getopts "plhm:s:" opt; do
case ${opt} in case ${opt} in
p ) p )
: ${PIZZAART:="pizza"} : ${PIZZAART:="pizza"}
@ -32,6 +34,9 @@ while getopts "plhm:" opt; do
m ) m )
PIZZARCV="${OPTARG}" PIZZARCV="${OPTARG}"
;; ;;
s )
PIZZASEND="${OPTARG}"
;;
h ) h )
help help
exit 0 exit 0
@ -44,6 +49,7 @@ while getopts "plhm:" opt; do
done done
: ${PIZZAART:="pizza"} : ${PIZZAART:="pizza"}
: ${PIZZASEND:="${PIZZAUSER}@${PIZZAHOST}"}
if [ ! $PIZZARCV ]; then if [ ! $PIZZARCV ]; then
echo "Argument '-m' and mailaddress needed!" echo "Argument '-m' and mailaddress needed!"
@ -51,5 +57,5 @@ if [ ! $PIZZARCV ]; then
exit 1 exit 1
fi fi
mail -s "${PIZZAUSER} sent you a ${PIZZAART} on ${PIZZAHOST}!" ${PIZZARCV} < "${PIZZAINC}/${PIZZAART}" mail -s "${PIZZAUSER} sent you a ${PIZZAART} on ${PIZZAHOST}!" -S from=${PIZZASEND} ${PIZZARCV} < "${PIZZAINC}/${PIZZAART}"
exit 0 exit 0