VirtualBox
#!/bin/bash
# A menu driven Shell script which has following options
# Contents of /etc/passwd
# List of users currently logged
# Prsent handling directory
# Exit
# As per option do the job
# -----------------------------------------------
# Copyright (c) 2005 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
while :
do
clear
echo " M A I N - M E N U"
echo "1. Sfs3 VM Start ..."
echo "2. Sfs3 VM Stop ..."
echo "3. Sfs3 VM savestate ..."
echo "4. Sfs3 VM poweroff ..."
echo "5. WWW VM Start ..."
echo "6. WWW VM Stop ..."
echo "7. WWW VM savestate ..."
echo "8. WWW VM Poweroff ..."
echo "A. List All VMS"
echo "R. List Running VMS"
echo "T. sudo ROOT"
echo "o. LogOut"
echo "x. Exit to command line"
echo .
sudo -H -b -u username /usr/bin/VBoxManage list runningvms
echo .
ps ax|grep startvm
echo .
echo -n "Please enter option [1 - 4,A,R,x]"
read opt
case $opt in
1) echo "************ Starting Sfs3 VM *************";
sudo -H -b -u username /usr/bin/VBoxHeadless --startvm "SFS3" --vrde off &
ps ax|grep VBox;
read
;;
2) echo "************ Stoping Sfs3 VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "SFS3" acpipowerbutton
ps ax|grep VBox;
read
;;
3) echo "************ Stoping Sfs3 VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "SFS3" savestate
ps ax|grep VBox;
read
;;
4) echo "************ Stoping Sfs3 VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "SFS3" poweroff
ps ax|grep VBox;
read
;;
5) echo "************ Starting WWW VM *************";
sudo -H -b -u username /usr/bin/VBoxHeadless --startvm "STP" --vrde off &
ps ax|grep VBox;
read
;;
6) echo "************ Stoping WWW VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "STP" acpipowerbutton
ps ax|grep VBox;
read
;;
7) echo "************ Stoping WWW VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "STP" savestate
ps ax|grep VBox;
read
;;
8) echo "************ Stoping WWW VM *************";
sudo -H -b -u username /usr/bin/VBoxManage controlvm "STP" poweroff
ps ax|grep VBox;
read
;;
A) echo "************ List All VMS *************";
sudo -H -b -u username /usr/bin/VBoxManage list vms
read
;;
R) echo "************ List Running VMS *************";
sudo -H -b -u username /usr/bin/VBoxManage list runningvms
echo .
echo .
ps ax|grep startvm
echo .
read
;;
T) echo "************ sudo -i *************";
sudo -i;;
o) echo "************ Logout *************";
exit 1;;
x) echo "************ Exit the menu *************";
echo "Exit menu"
break;;
*) echo "$opt is an invaild option. Please select option between 1-8,A,R,T,o,x only";
echo "Press [enter] key to continue. . .";
read enterKey;;
esac
done