killermist

keepalive.sh

Nov 8th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. if [[ -z "$1" ]];then echo "You forgot to include a pool/dataset name dummy.  Fix that, then try again." ; exit 1 ; fi  #rectify incorrect usage
  3. # keepalive.sh <poolname>
  4. ## Takes a pool name as the first and only parameter.
  5. #
  6. # Config:
  7. #
  8. MYNET="lan.killermist"
  9. # reverse order domain suffix.  In this case, torrents.killermist.lan = lan.killermist
  10. #
  11. ZFSVAR="keepalive"
  12. # An arbitrary ZFS variable suffix that shouldn't conflict with anything
  13. #
  14. # These will be combined into "$MYNET":"$ZFSVAR",
  15. # which in this case will be "lan.killermist:keepalive",
  16. # which should not conflict with any other variable used by any other bit of automation known
  17.  
  18. ## Every 20 seconds, sets the variable "$MYNET":"$ZFSVAR" with the current date/time in the
  19. ## (it is the least intrusive thing I could think of that is guaranteed to work)
  20. ## This commit to the pool will inhibit any possibility of the pool spinning down.
  21. ## When the pool disappears (it has been exported), the while condition fails.
  22. ## This breaking the loop, and the script ends.
  23.  
  24. while zfs set "$MYNET":"$ZFSVAR"=$(date +%F--%X) "$1"
  25. do sleep 20
  26. done
Add Comment
Please, Sign In to add comment