Advertisement
Guest User

Untitled

a guest
Mar 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. USER=qwe
  4. LISTFILE="/var/tmp/.vboxlistmashines"
  5.  
  6. case $1 in
  7. hibernate)
  8. echo "Hey guy, we are going to suspend to disk!"
  9. ;;
  10. suspend)
  11. su -c "xscreensaver-command -lock" - $USER
  12. su -c "VBoxManage list runningvms" - $USER | cut -d { -f2 | sed s/}//g >$LISTFILE
  13. for i in `cat $LISTFILE`; do su -c "VBoxManage controlvm $i savestate" - $USER; done
  14. echo "Oh, this time we are doing a suspend to RAM. Cool!"
  15. ;;
  16. thaw)
  17. echo "Oh, suspend to disk is over, we are resuming..."
  18. ;;
  19. resume)
  20. for i in `cat $LISTFILE`; do su -c "VBoxManage startvm $i" - $USER; done
  21. echo "Hey, the suspend to RAM seems to be over..."
  22. ;;
  23. *) echo "Somebody is calling me totally wrong."
  24. ;;
  25. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement