Restructured PIZZA-Script to be easier deployable

- Includes-directory can be set via PIZZAINC. This enables the user to
   put the ASCII-Art where he wants it

 - Hostname and user are now evaluated at the beginning and stored within
   PIZZAHOST and PIZZAUSER
This commit is contained in:
Oliver Rümpelein 2014-12-27 23:32:17 +01:00
parent f1ac1fa7c9
commit 8100a00246

10
src/pizza Normal file → Executable file
View file

@ -1,5 +1,9 @@
#!/bin/bash
: ${PIZZAINC:="/usr/local/share/pizza"}
PIZZAHOST=$(hostname -f)
PIZZAUSER=$(whoami)
help() {
echo "pizza - sent small ASCII-Icons by Mail"
echo "--------------------------------------"
@ -9,15 +13,15 @@ help() {
}
if [ ! "$2" ]; then
mail -s "$(whoami) sent you a Pizza on srv.r.f3l.de!" $1 < /usr/local/share/pizza/pizza.txt
mail -s "${PIZZAUSER} sent you a Pizza on ${PIZZAHOST}!" $1 < "${PIZZAINC}/pizza"
exit 0
else
case "$1" in
"-p" | "--pizza")
mail -s "$(whoami) sent you a Pizza on srv.r.f3l.de" $2 < /usr/local/share/pizza/pizza.txt
mail -s "${PIZZAUSER} sent you a Pizza on ${PIZZAHOST}" $2 < "${PIZZAINC}/pizza"
;;
"-l" | "--heart")
mail -s "$(whoami) sent you a Heart on srv.r.f3l.de" $2 < /usr/local/share/pizza/heart.txt
mail -s "${PIZZAUSER} sent you a Heart on ${PIZZAHOST}" $2 < "${PIZZAINC}/heart.txt"
;;
"-h" | "--help")
help