Advertisement
Guest User

/usr/local/bin/velocidad_transmission.sh

a guest
Jun 24th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1.  
  2. <pre class="brush: bash">
  3.  
  4. #!/bin/bash
  5. # programado por Juanmol para http://rsppi.blogspot.com
  6.  
  7. RESP=/tmp/webresp
  8. puerto=8998
  9. log=/var/log/cambios_velocidad_transmission.log
  10.  
  11. lento="/usr/local/bin/transmission-remote -as"
  12. rapido="/usr/local/bin/transmission-remote -AS"
  13.  
  14. [ -p $RESP ] || mkfifo $RESP
  15.  
  16. while true ; do
  17. ( cat $RESP ) | nc -l -p $puerto | (
  18. REQ=`while read L && [ " " "<" "$L" ] ; do echo "$L" ; done`
  19.  
  20. if [ "$(echo $REQ | head -1 | cut -f2 -d\/)" == "transmission" ];
  21. then
  22.         orden=$(echo  $REQ | head -1 | cut -f3 -d\/);
  23.         echo se recibe $orden a las $(date) >> $log ;
  24.         if [ "$orden" = "rapido" ];
  25.         then
  26.                 $rapido;
  27.         fi
  28.         if [ "$orden" = "lento" ];
  29.         then
  30.                 $lento;
  31.         fi
  32. fi
  33.  
  34.  
  35. cat >$RESP <<EOF
  36. HTTP/1.0 200 OK
  37. Cache-Control: private
  38. Content-Type: text/plain
  39. Server: bash/2.0
  40. Connection: Close
  41. Content-Length: 0
  42.  
  43. EOF
  44. )
  45. done
  46. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement