Guest User

utserver notification script

a guest
Jan 1st, 2012
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash -f
  2. NOTIFY_ADDRESS=nosuchuser@gmail.com
  3.  
  4. for arg in "$@"; do
  5.         label=${arg:0:1}
  6.         text=${arg:1}
  7.  
  8.         case $label in
  9.                 N ) NAME=$text ;;
  10.                 M ) STATUS=$text ;;
  11.                 S ) STATE=$text ;;
  12.                 D ) DIRECTORY=$text ;;
  13.                 P ) PREVIOUS_STATE=$text ;;
  14.                 K ) KIND=$text ;;
  15.         esac
  16. done
  17.  
  18. #if [ "$STATE" -ne 1 -a "$STATE" -ne 11 ]; then
  19. #       exit 0
  20. #fi;
  21.  
  22. if [ "$STATE" -eq 1 ]; then
  23.         exec sendmail $NOTIFY_ADDRESS << HERE
  24. Subject: [uT ERROR] $NAME
  25.  
  26. Torrent $NAME is now in an error state!
  27.  
  28. $STATUS
  29. HERE
  30. exit 0
  31. fi;
  32.  
  33. if [ "$STATE" -eq 5 -o $STATE -eq 8 ]; then
  34.         if [ $PREVIOUS_STATE -eq 10 ]; then
  35.                 # moved from queued seed to seed. this is noise.
  36.                 exit 0
  37.         fi;
  38.         exec sendmail $NOTIFY_ADDRESS << HERE
  39. Subject: [uT SEEDING] $NAME
  40.  
  41. Torrent $NAME is now complete!
  42. state: $STATE
  43. prevstate: $PREVIOUS_STATE
  44.  
  45. HERE
  46. exit 0
  47. fi;
  48.  
  49. exit 0
  50.  
  51. exec sendmail $NOTIFY_ADDRESS << HERE
  52. Subject: [uT MISC] $NAME
  53.  
  54. Torrent $NAME is now in state $STATUS ($STATE)
  55.  
  56. ###
  57. $@
  58. ###
  59.  
  60. $STATUS
  61. HERE
RAW Paste Data