Gmail Notifications for uTorrent Linux
I wrote a simple script and that along with ssmtp am able to be notified when torrents change status.
First you must setup your ssmtp environment.
SECURITY NOTE: Your password will be stored in plain text so I suggest creating a gmail account just for this.
sudo apt-get install ssmtp
nano /etc/ssmtp/ssmtp.conf
Replace the existing text (If any) in ssmtp.conf with the following:
First you must setup your ssmtp environment.
SECURITY NOTE: Your password will be stored in plain text so I suggest creating a gmail account just for this.
sudo apt-get install ssmtp
nano /etc/ssmtp/ssmtp.conf
Replace the existing text (If any) in ssmtp.conf with the following:
[email protected]
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=YOUR_GMAIL_USERNAME # (without @gmail.com)
AuthPass=YOUR_GMAIL_PASSWORD
FromLineOverride=YES UseTLS=YES
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=YOUR_GMAIL_USERNAME # (without @gmail.com)
AuthPass=YOUR_GMAIL_PASSWORD
FromLineOverride=YES UseTLS=YES
Remove Sendmail:
sudo service sendmail stop
sudo apt-get remove sendmail
Test your mail environment: Change the required values:
echo "test" | mail -s "email subject" [email protected]
Create the script
nano notify
Copy the following code to the notify file
be sure to change your_account to the gmail account you want to send to.
sudo service sendmail stop
sudo apt-get remove sendmail
Test your mail environment: Change the required values:
echo "test" | mail -s "email subject" [email protected]
Create the script
nano notify
Copy the following code to the notify file
be sure to change your_account to the gmail account you want to send to.
#!/bin/bash
/home/torrent/scripts/utorrent/./utorrent.py -l --format={name}={status}|sed '$d' > /home/torrent/scripts/utorrent/current.status
stats=$(diff /home/torrent/scripts/utorrent/old.status /home/torrent/scripts/utorrent/current.status)
mv /home/torrent/scripts/utorrent/current.status /home/torrent/scripts/utorrent/old.status
echo "$stats" > /home/torrent/scripts/utorrent/message.txt
if [ -z "$stats" ]
then
sleep 60
./notify
else
ssmtp your_account@gmail.com < /home/torrent/scripts/utorrent/message.txt
fi
rm /home/torrent/scripts/utorrent/message.txt
sleep 60
/home/torrent/scripts/utorrent/./notify
/home/torrent/scripts/utorrent/./utorrent.py -l --format={name}={status}|sed '$d' > /home/torrent/scripts/utorrent/current.status
stats=$(diff /home/torrent/scripts/utorrent/old.status /home/torrent/scripts/utorrent/current.status)
mv /home/torrent/scripts/utorrent/current.status /home/torrent/scripts/utorrent/old.status
echo "$stats" > /home/torrent/scripts/utorrent/message.txt
if [ -z "$stats" ]
then
sleep 60
./notify
else
ssmtp your_account@gmail.com < /home/torrent/scripts/utorrent/message.txt
fi
rm /home/torrent/scripts/utorrent/message.txt
sleep 60
/home/torrent/scripts/utorrent/./notify
chmod 775 notify
To start the script cd to the directory
nohup ./notify &
To start the script cd to the directory
nohup ./notify &