Posted By

matpolster on 02/04/10


Tagged

Samba ubuntu smb suspend


Versions (?)

Prevent s3 idle suspend when users connected to SMB


 / Published in: Bash
 

URL: http://ubuntuforums.org/showthread.php?t=1359820

I didn't write this!

  1. #!/bin/bash
  2.  
  3. if [ -f suspend.lock ]
  4. then
  5. date
  6. echo "Suspend aborted, restart lock file in place"
  7. exit 1
  8. fi
  9.  
  10. count=0
  11.  
  12. smbstatus > info.txt
  13. grep "No locked files" info.txt > /dev/null
  14.  
  15. while [ "$?" != "0" ]
  16. do
  17. date #debug purposes, see if it actually is running
  18. echo $count
  19. echo "Locked files, waiting"
  20. sleep 120
  21. count=`expr $count + 1`
  22.  
  23. if [ $count = 8 ]
  24. then
  25. date
  26. echo "Suspend aborted, too many attempts with locked files"
  27. exit 2
  28. fi
  29. smbstatus > info.txt
  30. grep "No locked files" info.txt > /dev/null
  31. done
  32.  
  33. date
  34. echo "Suspending Server"
  35. pmi action suspend
  36. exit 0

Report this snippet   <

You need to login to post a comment.