forked from gpkvt/modernie_selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateip.sh
executable file
·42 lines (35 loc) · 1.31 KB
/
updateip.sh
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
#!/bin/bash
nic_bridge="en0"
# Init; Do not change.
appliance=${1}
vm_name=False
vm_pretty_name=False
# Get informations about the given Appliance (Name, OS-Type, IE-Version)
get_vm_info() {
vm_info=$(VBoxManage import "${appliance}" -n)
chk fatal $? "Error getting Appliance Info"
vm_name=$(echo "${vm_info}" | grep "Suggested VM name" | awk -F'"' '{print $2}')
vm_pretty_name=$(echo "${vm_info}" | grep "Suggested VM name" | awk -F'"' '{print $2}' | sed 's/_/-/g' | sed 's/ //g' | sed 's/\.//g')
vm_os_type=$(echo "${vm_info}" | grep 'Suggested OS type' | awk -F'"' '{print $2}')
vm_ie=$(echo "${vm_name}" | awk -F' -' '{print $1}')
}
copyto() {
# $1 = filename, $2 = source directory, $3 destination directory
if [ ! -f "${2}${1}" ]
then
echo "Local file '${2}${1}' doesn't exist"
fi
execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${2}${1}\" \"${3}${1}\" --username 'IEUser' --password 'Passw0rd!'"
}
get_vm_info
# Create a hosts file
if [ $(uname) == "Darwin" ]
then
# This makes sense on a mac
ifconfig ${nic_bridge} | grep "inet " | awk '{print $2 " hubhost"}' > /tmp/hosts
else
# This works on Ubuntu
ifconfig ${nic_bridge} | grep "inet " | awk '{print $2 " hubhost"}' | sed 's/addr://' > /tmp/hosts
fi
# Send it to the VM
copyto hosts /tmp/ "C:/Windows/System32/drivers/etc/hosts"