summaryrefslogtreecommitdiff
path: root/sms.d/phone
blob: 4e08104d11f50778b438587ce7b958823f097588 (plain)
  1. #!/bin/sh
  2. # if an error occurs, break immediately
  3. set -e
  4. # Variables from Kannel sms gateway
  5. sms_phone="$SMS_PHONE"
  6. sms_fromphone="$1"
  7. app="$2"
  8. shift 2
  9. msg="$*"
  10. # Settings for the "mail" outgoing email command
  11. export smtp=mail.bitbase.dk
  12. export from=hp@fossasia.org
  13. export sender="$from"
  14. mail_subject="[sms] phone $sms_fromphone"
  15. mail_recipients="hp@fossasia.org mb@fossasia.org"
  16. doit() {
  17. # Send message (...to stdout if invoked from cmdline)
  18. if [ -n "$sms_phone" ]; then
  19. mail -s "$mail_subject" $mail_recipients
  20. else
  21. cat
  22. fi
  23. }
  24. # Check keyword and break after processing if it matches
  25. case "$app" in
  26. phone)
  27. cat <<EOF | doit
  28. Someone at $sms_fromphone sent an sms to $sms_phone with keyword phone
  29. and this message (supposedly his/her name):
  30. $msg
  31. EOF
  32. exit 1
  33. ;;
  34. esac