-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.bash.example
executable file
·55 lines (43 loc) · 1.29 KB
/
env.bash.example
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
55
#!/bin/bash
# env.bash
# virtual machine template to clone from
export ORIGINAL="dnet"
# used for resetting host ssh key on clones
# /etc/ssh/ssh_host_ed25519_key.pub for comparision
export ORIGINAL_SSH_ED25519PUB=""
# /etc/machine-id or /var/lib/dbus/machine-id for comparision
export ORIGINAL_MACHINE_ID=""
export MACHINES=("${ORIGINAL}one" "${ORIGINAL}two" "${ORIGINAL}three" "${ORIGINAL}four" "${ORIGINAL}five")
# derived from the subnet by which the
# vms are attached to the physical host machine
export SUBNET_FRAGMENT="10.55.44"
export BRIDGES=("vm_router_lab_upper_bridge" "vm_router_lab_lower_bridge")
# your user name on physical host
PHYSICAL_HOST_USER=""
export USER_UID="1000"
PHYSICAL_HOST_HOSTNAME=""
export LIBVIRT_DEFAULT_URI="qemu+ssh://${PHYSICAL_HOST_USER}@${PHYSICAL_HOST_HOSTNAME}/system"
function start_vm() {
local is_inactive
is_inactive="$(virsh list --inactive | awk '{print $2}' | grep "^${1}$" -c)"
if [ "${is_inactive}" == "1" ]
then
echo starting "${1}"
virsh start "${1}"
fi
}
export -f start_vm
function check_uid() {
if [ "${1}" != "${UID}" ]
then
if [ "${1}" == "0" ]
then
echo this script should be run as the root user
exit
else
echo this script should not be run as root user
exit
fi
fi
}
export -f check_uid