pump.sh 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. linea=$1
  3. tempo=$2
  4. pompasi=1
  5. pompa=10
  6. log=$(mktemp)
  7. if [ __${tempo}__ == ____ ] ; then
  8. echo "non e' stato indicato il tempo, si va in automatico" |tee -a ${log}
  9. tempo=30s
  10. fi
  11. # verifica la presenza del file "irrigatore" |tee -a ${log}
  12. if [ -f ~/script/irrigatore ]; then
  13. echo "File 'irrigatore' presente" |tee -a ${log}
  14. echo "Apertura valvola ${linea} per ${tempo}" |tee -a ${log}
  15. raspi-gpio set ${linea} dl
  16. if [ ${pompasi} == 1 ]; then
  17. echo "Accensione pompa ${pompa}" |tee -a ${log}
  18. raspi-gpio set ${pompa} dl
  19. fi
  20. sleep ${tempo}
  21. if [ ${pompasi} == 1 ]; then
  22. echo "Spengo pompa ${pompa}" |tee -a ${log}
  23. raspi-gpio set ${pompa} dh
  24. fi
  25. echo "Chiusura valvola ${linea}" |tee -a ${log}
  26. raspi-gpio set ${linea} dh
  27. else
  28. echo "Accensione linea ${linea} per ${tempo}\nDisattivata: manca file 'irrigatore' in home" |tee -a ${log}
  29. fi
  30. cat ${log} | mail -s "linea ${linea} per ${tempo}" root
  31. rm ${log}
  32. #dl lo attiva
  33. #dh lo disattiva
  34. #op abilita la linea