parseMail.sh 565 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash -x
  2. . ./config.sh
  3. FILE=$1; shift;
  4. oldIFS="$IFS"
  5. IFS=":"
  6. MAILDATA=($(awk -F ': ' '{if ($1=="To") {to=$2} if ($1=="From") {from=$2} if ($1=="Subject") {subject=$2} lastline=$1 } END {print from":"to":"subject":"lastline}' < "$FILE"))
  7. rm -f "$FILE"
  8. IFS="$oldIFS"
  9. echo "${MAILDATA[2]}"
  10. SUBSCRIBER="${MAILDATA[0]}"
  11. SIGNATURE="${MAILDATA[3]}"
  12. SIGNATURECHECKVALUE="$(echo -n "$SUBSCRIBER$SITE_SECRET" | sha512sum | awk '{print $1}')"
  13. if [ "$SIGNATURE" != "$SIGNATURECHECKVALUE" ]; then
  14. exit -1
  15. fi
  16. echo "$SUBSCRIBER" | add_members -r - news
  17. exit 0