-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-vm
executable file
·54 lines (48 loc) · 962 Bytes
/
create-vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
START_TIME=$SECONDS
# Set default values
#export DIST=xenial
export DIST=bionic
export ARCH=64
export GUI=lubuntu
export VNX=yes
export HNAME=vnxsdn-vm
export NEWUSER=upm
export NEWPASSWD=xxxx
export VMLANG=es
export MEM=2048
export VCPUS=2
Usage="--
-- Usage: create-vm [-c <conf_file>] [-h]
--"
while getopts ":hc:" opt; do
case $opt in
c)
CFGFILE=$OPTARG
if [ ! -e $CFGFILE ]; then
echo "-- ERROR: config file '$CFGFILE' not found"
exit 1
fi
source $CFGFILE
;;
h)
#echo "-h was triggered!" >&2
echo "$Usage"
exit 0
;;
\?)
echo "-- ERROR: invalid option -$OPTARG" >&2
;;
:)
echo "-- ERROR: option -$OPTARG requires an argument" >&2
echo "$Usage"
exit 1
;;
esac
done
echo "DIST=$DIST"
vagrant up
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "--"
echo "-- Virtual machine created in $ELAPSED_TIME seconds"
echo "--"