correct drives bug with uefi mode
This commit is contained in:
parent
177b5cec3e
commit
f4177bdbd4
1 changed files with 41 additions and 28 deletions
69
vm-start.sh
69
vm-start.sh
|
@ -12,29 +12,30 @@ Script to manage virtual machine easily.
|
|||
NAME is the name of the virtual machine to use.
|
||||
|
||||
COMMAND available
|
||||
init Create the conf file in conf/NAME_var.sh
|
||||
start Start the virtual machine using the variabes in conf/NAME_var.sh
|
||||
start-backup Start the virtual machine using the backup volume if it exists.
|
||||
create Create the virtual machine using the conf in conf/NAME_var.sh
|
||||
backup Create a backup file for the vm
|
||||
restore Restore the virtual machine using to backup file
|
||||
suppr Suppr all data related to the virtual machine other than the conf file.
|
||||
init Create the conf file in conf/NAME_var.sh
|
||||
start Start the virtual machine using the variabes in conf/NAME_var.sh
|
||||
start-backup Start the virtual machine using the backup volume if it exists.
|
||||
create Create the virtual machine using the conf in conf/NAME_var.sh
|
||||
backup Create a backup file for the vm
|
||||
restore Restore the virtual machine using to backup file
|
||||
suppr Suppr all data related to the virtual machine other than the conf file.
|
||||
|
||||
COMMAND TODO
|
||||
suppr-all Suppr all data related to the vm even the conf file #TODO
|
||||
suppr-all Suppr all data related to the vm even the conf file #TODO
|
||||
|
||||
PARAMETTER available
|
||||
-h, --help Print this help and exit
|
||||
-v, --version Print the version of this program and quit
|
||||
-h, --help Print this help and exit
|
||||
-v, --version Print the version of this program and quit
|
||||
|
||||
OPTION available
|
||||
nproc=<nb proc> Def the number of proc of the vm
|
||||
memory=<mem> Def the qty of memory allocated to the vm
|
||||
size=<size> Def the size that should be allocated by create
|
||||
uefi Select if there will be an UEFI by default.
|
||||
can be either set or unset. By default is unset.
|
||||
options=<option> additinal options to give to qemu. By default is
|
||||
-display gtk -vga qxl
|
||||
nproc=<nb proc> Def the number of proc of the vm
|
||||
memory=<mem> Def the qty of memory allocated to the vm
|
||||
size=<size> Def the size that should be allocated by create
|
||||
uefi Select if there will be an UEFI by default.
|
||||
can be either set or unset. By default is unset.
|
||||
options=<option> additinal options to give to qemu. By default is
|
||||
-display gtk -vga qxl
|
||||
create_disk=<loc_disk> Def a create disk to boot on. Is necessary for using create, or need the variable INSTALLATION_DISK_LOCATION to be set.
|
||||
"
|
||||
MAIN_LOCATION="$HOME/virtual_machine"
|
||||
OPTION="-display gtk \
|
||||
|
@ -89,7 +90,7 @@ start_the_vm() {
|
|||
-net nic \
|
||||
-net user"$FORWARD",hostname="$VMHOSTNAME" \
|
||||
-m "$MEMORY" \
|
||||
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}" \
|
||||
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}",index=2,id=maindrive,media=disk \
|
||||
$OPTION
|
||||
|
||||
}
|
||||
|
@ -132,7 +133,8 @@ CREATE() {
|
|||
|
||||
OPTION="$OPTION \
|
||||
-boot d \
|
||||
-drive file=$1,media=cdrom"
|
||||
-drive file=$1,if=none,media=cdrom,id=drive-cd1 \
|
||||
-device ide-cd,drive=drive-cd1,id=cd1,bootindex=1"
|
||||
|
||||
start_the_vm
|
||||
|
||||
|
@ -208,13 +210,16 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit
|
|||
# Véréfie qu'il y ait bien un fichier de config pour la vm que l'on tente de démarer dans la cas contraire en génére un.
|
||||
# possibilitée de générer à nouveau le fichier de config avec vm-start nom-vm init
|
||||
|
||||
if [ "$2" == "init" ]
|
||||
then
|
||||
INIT "$1"
|
||||
elif [ ! -f "conf/$1-vm_var.sh" ]
|
||||
if [ ! -f "conf/$1-vm_var.sh" ]
|
||||
then
|
||||
echo "no config file found. creating one in conf/${1}-vm_var.sh"
|
||||
INIT "$1"
|
||||
|
||||
if [ "$2" == "init" ]
|
||||
then
|
||||
# Exit, it is the end of the program.
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#Vérifie si l'option UEFI est set dans le fichier de config. Si oui l'ajoutte aux options.
|
||||
|
@ -232,6 +237,11 @@ for (( i=3; i<=$#; i++)); do
|
|||
"uefi")
|
||||
set_uefi
|
||||
;;
|
||||
"create_disk")
|
||||
INSTALLATION_DISK_LOCATION="${!i#*=}"
|
||||
echo "${!i#*=}"
|
||||
echo "${INSTALLATION_DISK_LOCATION}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -261,12 +271,11 @@ case "$2" in
|
|||
;;
|
||||
"create")
|
||||
echo "creating VM"
|
||||
if [ $# -ge 3 ]
|
||||
if [ ! "${INSTALLATION_DISK_LOCATION}" == "" ]
|
||||
then
|
||||
echo "using image disk $3"
|
||||
CREATE "$3"
|
||||
echo "using image disk ${INSTALLATION_DISK_LOCATION}"
|
||||
CREATE "${INSTALLATION_DISK_LOCATION}"
|
||||
else
|
||||
echo "$#"
|
||||
echo "Error, no image defined." >&2
|
||||
fi
|
||||
;;
|
||||
|
@ -274,7 +283,11 @@ case "$2" in
|
|||
echo "suppressing all data of the vm $1"
|
||||
SUPPRESS "$1"
|
||||
;;
|
||||
"*")
|
||||
"init")
|
||||
echo "Init volume $1"
|
||||
INIT "$1"
|
||||
;;
|
||||
*)
|
||||
echo "commande $2 inconnue" >&2
|
||||
HELP
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue