From 04f45090460f66a31e7c50fc356fceca6fc02c5f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 16 May 2010 15:59:38 +0000 Subject: [PATCH] (trunk) sample script to send an email or SMS message when a torrent finishes downloading --- doc/Makefile.am | 3 +- doc/send-email-when-torrent-done.sh | 53 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 doc/send-email-when-torrent-done.sh diff --git a/doc/Makefile.am b/doc/Makefile.am index 6eb3b7002..af6ef5c76 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1 +1,2 @@ -EXTRA_DIST = rpc-spec.txt +EXTRA_DIST = rpc-spec.txt \ + send-email-when-torrent-done.sh diff --git a/doc/send-email-when-torrent-done.sh b/doc/send-email-when-torrent-done.sh new file mode 100755 index 000000000..ff4416486 --- /dev/null +++ b/doc/send-email-when-torrent-done.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +## +## User-configurable Variables +## + +# Where "nail" is installed on your system. +# We need this to actually send the mail, so make sure it's installed +NAIL=/usr/bin/nail + +# REQUIRED CHANGE #1: you must set SMTP_SERVER +# http://www.host45.com/resources/ispsmtps.php has a list of ISP's smtp servers +SMTP_SERVER=your.smtp.server + +# REQUIRED CHANGE #2: you must set your email address. +# option A: change "yourname@yourmail.com" here and remove the leading '#' to +# use a real email address +#TO_ADDR=yourname@yourmail.com +# +# option B: for an SMS message, set your phone number here and remove the +# leading '#' on the PHONENUM line and your phone provider's TO_ADDR line +#PHONENUM="1234567890" +#TO_ADDR="$PHONENUM@message.alltel.com" # SMS: Alltel +#TO_ADDR="$PHONENUM@txt.att.net" # SMS: AT&T (formerly Cingular) +#TO_ADDR="$PHONENUM@myboostmobile.com" # SMS: Boost Mobile +#TO_ADDR="$PHONENUM@sms.mycricket.com" # SMS: Cricket Wireless +#TO_ADDR="$PHONENUM@messaging.nextel.com" # SMS: Nextel (Sprint Nextel) +#TO_ADDR="$PHONENUM@messaging.sprintpcs.com" # SMS: Sprint (Sprint Nextel) +#TO_ADDR="$PHONENUM@tmomail.net" # SMS: T-Mobile +#TO_ADDR="$PHONENUM@vtext.com" # SMS: Verizon +#TO_ADDR="$PHONENUM@vmobl.com" # SMS: Virgin Mobile USA +#TO_ADDR="$PHONENUM@txt.bellmobility.ca" # SMS: Bell Canada +#TO_ADDR="$PHONENUM@cwemail.com" # SMS: Centennial Wireless +#TO_ADDR="$PHONENUM@csouth1.com" # SMS: Cellular Sout +#TO_ADDR="$PHONENUM@gocbw.com" # SMS: Cincinnati Bell +#TO_ADDR="$PHONENUM@mymetropcs.com" # SMS: Metro PCS 1 +#TO_ADDR="$PHONENUM@metropcs.sms.us" # SMS: Metro PCS 2 +#TO_ADDR="$PHONENUM@qwestmp.com" # SMS: Quest +#TO_ADDR="$PHONENUM@pcs.rogers.com" # SMS: Rogers +#TO_ADDR="$PHONENUM@tms.suncom.com" # SMS: Suncom +#TO_ADDR="$PHONENUM@msg.telus.com" # SMS: Telus +#TO_ADDR="$PHONENUM@email.uscc.net" # SMS: U.S. Cellular + +### +### Send the mail... +### + +SUBJECT="Torrent Done!" +FROM_ADDR="transmission@localhost.localdomain" +TMPFILE=`mktemp -t transmission.XXXXXXXXXX` +echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" >$TMPFILE +$NAIL -v -S from="$FROM_ADDR" -S smtp -s "$SUBJECT" -S smtp=$SMTP_SERVER "$TO_ADDR" < $TMPFILE +rm $TMPFILE