Advertisement
wojtekadams

Automatically wake NAS/server on playback request

Mar 30th, 2023 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. # source: https://forum.kodi.tv/showthread.php?tid=118164
  3.  
  4.  
  5. #ping server ip in case its already up
  6. ping -c 1 -w 1 -q SERVERIP > /dev/null
  7. status=$?
  8. logger "AUTOFS: Attempting to mount $1 filesystem from SERVERIP"
  9. logger "AUTOFS: Result from ping - $status"
  10. if [ $status -ne 0 ]
  11. then
  12. logger "AUTOFS: Host is not up. Sending wake-on-lan"
  13. /usr/sbin/etherwake SERVERMAC
  14. logger "AUTOFS: Sleeping for 5 seconds to allow host to wake"
  15. sleep 5
  16. fi
  17.  
  18. logger "AUTOFS: Re-pinging host"
  19. ping -c 1 -w 1 -q SERVERIP > /dev/null
  20. status=$?
  21. logger "AUTOFS: Result - $status"
  22.  
  23. if [ $status -eq 0 ]
  24. then
  25. logger "AUTOFS: Mounting $1 filesystem"
  26. #echo out autofs settings. Mount $1 share. $1 is passed in by autofs
  27. /bin/echo -n "-fstype=smbfs,rw,username=user,password=password ://SERVERIP/$1"
  28. wget --delete-after "http://httpuser:httppass@localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Erfolgreich,NAS%20wurde%20geweckt))"
  29. else
  30. logger "AUTOFS: Still no ping result from host"
  31. wget --delete-after "http://httpuser:httppass@localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Fehlgeschlagen,Nas%20konnte%20nicht%20geweckt%20werden))"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement