Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

can now start or suspend from select options

  • Loading branch information...
commit c4a5b188b6c578c245d9936c38e96d30e863c6de 1 parent 4adf0a5
@blturner authored
Showing with 34 additions and 5 deletions.
  1. +34 −5 vm.sh
View
39 vm.sh
@@ -7,22 +7,51 @@
# * Show running VMs and enable stopping
# * Check VMWare exists and exit if it doesn't (cross-platform)
+startflag=
+pauseflag=
+stopflag=
+while getopts 'sp' OPTION
+do
+ case $OPTION in
+ s) startflag=1
+ ;;
+ p) pauseflag=1
+ ;;
+ ?) printf "Usage %s: [-s] [-p] args\n" $(basename $0) >&2
+ exit 2
+ ;;
+ esac
+done
+
VM_DIR="${HOME}/Documents/Virtual Machines.localized"
-VM_COMMAND="/Library/Application Support/VMware Fusion/vmrun"
-VM_LIST=`find "${VM_DIR}" -name "*.vmwarevm" | grep -v 'Win' | grep -v 'XP'`
+VMRUN="/Library/Application Support/VMware Fusion/vmrun"
+
+if [ "$startflag" ]
+then
+ VM_LIST=`find "${VM_DIR}" -name "*.vmwarevm" | grep -v 'Win' | grep -v 'XP'`
+ VM_COMMAND="start"
+ EXTRA="nogui"
+fi
+
+if [ "$pauseflag" ]
+then
+ VM_LIST=`"${VMRUN}" list`
+ VM_COMMAND="suspend"
+ EXTRA="soft"
+fi
# path separators so I can use spaces in filenames
OLD_IFS=${IFS}; IFS="
"
-echo "Choose a non-Windows VM to start:"
+echo "Choose a non-Windows VM to $VM_COMMAND:"
select opt in $VM_LIST ; do
# run file
- `"${VM_COMMAND}" start "${opt}" nogui`
+ `"${VMRUN}" "$VM_COMMAND" "${opt}" "${EXTRA}"`
# repair IFS
IFS=${OLD_IFS}
exit 0
done
IFS=${OLD_IFS}
-exit 1
+exit 1
Please sign in to comment.
Something went wrong with that request. Please try again.