Skip to content
Newer
Older
100755 505 lines (419 sloc) 16 KB
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 6, 2011
1 #!/usr/bin/env bash
2
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
3 # Caution is a virtue.
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
4 set -o nounset
5 set -o errtrace
6 set -o errexit
7 set -o pipefail
8
b3fb502 @singingwolfboy Fix typo
singingwolfboy authored Jul 29, 2014
9 # ## Global Variables
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
10
0a9b131 @xdissent Refactor
authored Jun 21, 2013
11 # The ievms version.
1de5491 @xdissent Bump
authored Aug 21, 2015
12 ievms_version="0.3.1"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
13
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
14 # Options passed to each `curl` command.
c676542 @xdissent Tweak curl stuff further and add resume to all downloads where suppor…
authored May 28, 2012
15 curl_opts=${CURL_OPTS:-""}
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
16
17 # Reuse XP virtual machines for IE versions that are supported.
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 2, 2013
18 reuse_xp=${REUSE_XP:-"yes"}
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
19
20 # Reuse Win7 virtual machines for IE versions that are supported.
21 reuse_win7=${REUSE_WIN7:-"yes"}
22
23 # Timeout interval to wait between checks for various states.
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
24 sleep_wait="5"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
25
26 # Store the original `cwd`.
72f48ba @xdissent Fix iso path for dev env
authored Jun 12, 2013
27 orig_cwd=`pwd`
fa16f16 @rcmachado Adds a $CURL_EXTRA_OPTS variable
rcmachado authored Dec 13, 2011
28
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
29 # The VM user to use for guest control.
30 guest_user="IEUser"
31
32 # The VM user password to use for guest control.
33 guest_pass="Passw0rd!"
34
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
35 # ## Utilities
36
37 # Print a message to the console.
a61715d @xdissent Fix log escape handling
authored Aug 21, 2015
38 log() { printf '%s\n' "$*" ; return $? ; }
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
39
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
40 # Print an error message to the console and bail out of the script.
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
41 fail() { log "\nERROR: $*\n" ; exit 1 ; }
42
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
43 check_md5() {
44 local md5
45
46 case $kernel in
47 Darwin) md5=`md5 "${1}" | rev | cut -c-32 | rev` ;;
48 Linux) md5=`md5sum "${1}" | cut -c-32` ;;
49 esac
50
51 if [ "${md5}" != "${2}" ]
52 then
53 log "MD5 check failed for ${1} (wanted ${2}, got ${md5})"
54 return 1
55 fi
56
57 log "MD5 check succeeded for ${1}"
58 }
59
0a9b131 @xdissent Refactor
authored Jun 21, 2013
60 # Download a URL to a local file. Accepts a name, URL and file.
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
61 download() { # name url path md5
62 local attempt=${5:-"0"}
63 local max=${6:-"3"}
64
65 let attempt+=1
66
0a9b131 @xdissent Refactor
authored Jun 21, 2013
67 if [[ -f "${3}" ]]
68 then
69 log "Found ${1} at ${3} - skipping download"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
70 check_md5 "${3}" "${4}" && return 0
71 log "Check failed - redownloading ${1}"
72 rm -f "${3}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
73 fi
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
74
75 log "Downloading ${1} from ${2} to ${3} (attempt ${attempt} of ${max})"
76 curl ${curl_opts} -L "${2}" -o "${3}" || fail "Failed to download ${2} to ${ievms_home}/${3} using 'curl', error code ($?)"
77 check_md5 "${3}" "${4}" && return 0
78
79 if [ "${attempt}" == "${max}" ]
80 then
81 echo "Failed to download ${2} to ${ievms_home}/${3} (attempt ${attempt} of ${max})"
82 return 1
83 fi
84
85 log "Redownloading ${1}"
86 download "${1}" "${2}" "${3}" "${4}" "${attempt}" "${max}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
87 }
88
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
89 # ## General Setup
90
91 # Create the ievms home folder and `cd` into it. The `INSTALL_PATH` env variable
0a9b131 @xdissent Refactor
authored Jun 21, 2013
92 # is used to determine the full path. The home folder is then added to `PATH`.
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
93 create_home() {
0a9b131 @xdissent Refactor
authored Jun 21, 2013
94 local def_ievms_home="${HOME}/.ievms"
6566760 @xdissent Fixed home path determination with `nounset`
authored Sep 29, 2011
95 ievms_home=${INSTALL_PATH:-$def_ievms_home}
9861e23 Adding INSTALL_PATH option
Adam Jahnke authored Sep 28, 2011
96
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
97 mkdir -p "${ievms_home}"
98 cd "${ievms_home}"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
99
0a9b131 @xdissent Refactor
authored Jun 21, 2013
100 PATH="${PATH}:${ievms_home}"
101
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
102 # Move ovas and zips from a very old installation into place.
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
103 mv -f ./ova/IE*/IE*.{ova,zip} "${ievms_home}/" 2>/dev/null || true
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
104 }
105
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
106 # Check for a supported host system (Linux/OS X).
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
107 check_system() {
108 kernel=`uname -s`
109 case $kernel in
110 Darwin|Linux) ;;
111 *) fail "Sorry, $kernel is not supported." ;;
112 esac
113 }
114
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
115 # Ensure VirtualBox is installed and `VBoxManage` is on the `PATH`.
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
116 check_virtualbox() {
117 log "Checking for VirtualBox"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
118 hash VBoxManage 2>&- || fail "VirtualBox command line utilities are not installed, please (re)install! (http://virtualbox.org)"
ebd97dc @xdissent Better checks for ext pack versions fixes #9 #27 #46 #57 #68 #71 #74 #77
authored Sep 23, 2012
119 }
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
120
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
121 # Determine the VirtualBox version details, querying the download page to ensure
122 # validity.
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
123 check_version() {
0a9b131 @xdissent Refactor
authored Jun 21, 2013
124 local version=`VBoxManage -v`
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
125 major_minor_release="${version%%[-_r]*}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
126 local major_minor="${version%.*}"
127 local dl_page=`curl ${curl_opts} -L "http://download.virtualbox.org/virtualbox/" 2>/dev/null`
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
128
478fd3b @whiteinge Added check for unloaded kernel module in version output
whiteinge authored Jan 30, 2013
129 if [[ "$version" == *"kernel module is not loaded"* ]]; then
130 fail "$version"
131 fi
132
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
133 for (( release="${major_minor_release#*.*.}"; release >= 0; release-- ))
134 do
135 major_minor_release="${major_minor}.${release}"
136 if echo $dl_page | grep "${major_minor_release}/" &>/dev/null
137 then
138 log "Virtualbox version ${major_minor_release} found."
139 break
140 else
0a9b131 @xdissent Refactor
authored Jun 21, 2013
141 log "Virtualbox version ${major_minor_release} not found, skipping."
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
142 fi
143 done
144 }
145
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
146 # Check for the VirtualBox Extension Pack and install if not found.
ebd97dc @xdissent Better checks for ext pack versions fixes #9 #27 #46 #57 #68 #71 #74 #77
authored Sep 23, 2012
147 check_ext_pack() {
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
148 log "Checking for Oracle VM VirtualBox Extension Pack"
149 if ! VBoxManage list extpacks | grep "Oracle VM VirtualBox Extension Pack"
150 then
f2cf840 @xdissent Download GA ISO if not found.
authored Sep 23, 2012
151 check_version
0a9b131 @xdissent Refactor
authored Jun 21, 2013
152 local archive="Oracle_VM_VirtualBox_Extension_Pack-${major_minor_release}.vbox-extpack"
153 local url="http://download.virtualbox.org/virtualbox/${major_minor_release}/${archive}"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
154 local md5s="https://www.virtualbox.org/download/hashes/${major_minor_release}/MD5SUMS"
155 local md5=`curl ${curl_opts} -L "${md5s}" | grep "${archive}" | cut -c-32`
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
156
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
157 download "Oracle VM VirtualBox Extension Pack" "${url}" "${archive}" "${md5}"
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
158
159 log "Installing Oracle VM VirtualBox Extension Pack from ${ievms_home}/${archive}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
160 VBoxManage extpack install "${archive}" || fail "Failed to install Oracle VM VirtualBox Extension Pack from ${ievms_home}/${archive}, error code ($?)"
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
161 fi
162 }
163
0a9b131 @xdissent Refactor
authored Jun 21, 2013
164 # Download and install `unar` from Google Code.
165 install_unar() {
166 local url="http://theunarchiver.googlecode.com/files/unar1.5.zip"
167 local archive=`basename "${url}"`
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
168
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
169 download "unar" "${url}" "${archive}" "fbf544d1332c481d7d0f4e3433fbe53b"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
170
0a9b131 @xdissent Refactor
authored Jun 21, 2013
171 unzip "${archive}" || fail "Failed to extract ${ievms_home}/${archive} to ${ievms_home}/, unzip command returned error code $?"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
172
173 hash unar 2>&- || fail "Could not find unar in ${ievms_home}"
174 }
175
0a9b131 @xdissent Refactor
authored Jun 21, 2013
176 # Check for the `unar` command, downloading and installing it if not found.
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
177 check_unar() {
178 if [ "${kernel}" == "Darwin" ]
179 then
0a9b131 @xdissent Refactor
authored Jun 21, 2013
180 hash unar 2>&- || install_unar
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
181 else
ae363e0 @xdissent Use unar for Linux too. fixes #120
authored Feb 5, 2013
182 hash unar 2>&- || fail "Linux support requires unar (sudo apt-get install for Ubuntu/Debian)"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
183 fi
184 }
185
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
186 # Pause execution until the virtual machine with a given name shuts down.
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
187 wait_for_shutdown() {
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
188 while true ; do
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
189 log "Waiting for ${1} to shutdown..."
190 sleep "${sleep_wait}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
191 VBoxManage showvminfo "${1}" | grep "State:" | grep -q "powered off" && return 0 || true
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
192 done
193 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
194
0a9b131 @xdissent Refactor
authored Jun 21, 2013
195 # Pause execution until guest control is available for a virtual machine.
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
196 wait_for_guestcontrol() {
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
197 while true ; do
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
198 log "Waiting for ${1} to be available for guestcontrol..."
199 sleep "${sleep_wait}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
200 VBoxManage showvminfo "${1}" | grep 'Additions run level:' | grep -q "3" && return 0 || true
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
201 done
202 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
203
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
204 # Find or download the ievms control ISO.
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
205 find_iso() {
0a9b131 @xdissent Refactor
authored Jun 21, 2013
206 local url="https://dl.dropboxusercontent.com/u/463624/ievms-control-${ievms_version}.iso"
207 local dev_iso="${orig_cwd}/ievms-control.iso" # Use local iso if in ievms dev root
208 if [[ -f "${dev_iso}" ]]
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
209 then
0a9b131 @xdissent Refactor
authored Jun 21, 2013
210 iso=$dev_iso
211 else
212 iso="${ievms_home}/ievms-control-${ievms_version}.iso"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
213 download "ievms control ISO" "${url}" "${iso}" "6699cb421fc2f56e854fd3f5e143e84c"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
214 fi
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
215 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
216
0a9b131 @xdissent Refactor
authored Jun 21, 2013
217 # Attach a dvd image to the virtual machine.
218 attach() {
219 log "Attaching ${3}"
220 VBoxManage storageattach "${1}" --storagectl "IDE Controller" --port 1 \
221 --device 0 --type dvddrive --medium "${2}"
222 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
223
0a9b131 @xdissent Refactor
authored Jun 21, 2013
224 # Eject the dvd image from the virtual machine.
225 eject() {
226 log "Ejecting ${2}"
227 VBoxManage modifyvm "${1}" --dvd none
228 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
229
0a9b131 @xdissent Refactor
authored Jun 21, 2013
230 # Boot the virtual machine with the control ISO in the dvd drive then wait for
231 # it to do its magic and shut down. For XP images, the "magic" is simply
232 # enabling guest control without a password. For other images, it installs
233 # a batch file that runs on first boot to install guest additions and activate
234 # the OS if possible.
235 boot_ievms() {
236 find_iso
237 attach "${1}" "${iso}" "ievms control ISO"
238 start_vm "${1}"
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
239 wait_for_shutdown "${1}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
240 eject "${1}" "ievms control ISO"
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
241 }
242
0a9b131 @xdissent Refactor
authored Jun 21, 2013
243 # Boot the virtual machine with guest additions in the dvd drive. After running
244 # `boot_ievms`, the next boot will attempt automatically install guest additions
245 # if present in the drive. It will shut itself down after installation.
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
246 boot_auto_ga() {
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
247 boot_ievms "${1}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
248 attach "${1}" "additions" "Guest Additions"
249 start_vm "${1}"
250 wait_for_shutdown "${1}"
251 eject "${1}" "Guest Additions"
252 }
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
253
0a9b131 @xdissent Refactor
authored Jun 21, 2013
254 # Start a virtual machine in headless mode.
255 start_vm() {
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
256 log "Starting VM ${1}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
257 VBoxManage startvm "${1}" --type headless
258 }
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
259
827286c @xdissent Update for VirtualBox 5.0
authored Aug 20, 2015
260 # Copy a file to the virtual machine from the ievms home folder.
0a9b131 @xdissent Refactor
authored Jun 21, 2013
261 copy_to_vm() {
262 log "Copying ${2} to ${3}"
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
263 guest_control_exec "${1}" cmd.exe /c copy "E:\\${2}" "${3}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
264 }
265
266 # Execute a command with arguments on a virtual machine.
267 guest_control_exec() {
268 local vm="${1}"
269 local image="${2}"
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
270 shift
271 VBoxManage guestcontrol "${vm}" run \
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
272 --username "${guest_user}" --password "${guest_pass}" \
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
273 --exe "${image}" -- "$@"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
274 }
275
276 # Start an XP virtual machine and set the password for the guest user.
277 set_xp_password() {
278 start_vm "${1}"
279 wait_for_guestcontrol "${1}"
280
281 log "Setting ${guest_user} password"
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
282 VBoxManage guestcontrol "${1}" run --username Administrator \
283 --password "${guest_pass}" --exe "net.exe" -- \
284 net.exe user "${guest_user}" "${guest_pass}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
285
286 log "Setting auto logon password"
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
287 VBoxManage guestcontrol "${1}" run --username Administrator \
288 --password "${guest_pass}" --exe "reg.exe" -- reg.exe add \
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
289 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" \
290 /f /v DefaultPassword /t REG_SZ /d "${guest_pass}"
291
292 log "Enabling auto admin logon"
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
293 VBoxManage guestcontrol "${1}" run --username Administrator \
294 --password "${guest_pass}" --exe "reg.exe" -- reg.exe add \
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
295 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" \
296 /f /v AutoAdminLogon /t REG_SZ /d 1
297 }
298
299 # Shutdown an XP virtual machine and wait for it to power off.
300 shutdown_xp() {
301 log "Shutting down ${1}"
302 guest_control_exec "${1}" "shutdown.exe" /s /f /t 0
303 wait_for_shutdown "${1}"
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
304 }
305
0a9b131 @xdissent Refactor
authored Jun 21, 2013
306 # Install an alternative version of IE in an XP virtual machine. Downloads the
307 # installer, copies it to the vm, then runs it before shutting down.
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
308 install_ie_xp() { # vm url md5
0a9b131 @xdissent Refactor
authored Jun 21, 2013
309 local src=`basename "${2}"`
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
310 local dest="C:\\Documents and Settings\\${guest_user}\\Desktop\\${src}"
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
311
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
312 download "${src}" "${2}" "${src}" "${3}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
313 copy_to_vm "${1}" "${src}" "${dest}"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
314
0a9b131 @xdissent Refactor
authored Jun 21, 2013
315 log "Installing IE" # Always "fails"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
316 guest_control_exec "${1}" "${dest}" /passive /norestart || true
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
317
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
318 shutdown_xp "${1}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
319 }
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
320
0a9b131 @xdissent Refactor
authored Jun 21, 2013
321 # Install an alternative version of IE in a Win7 virtual machine. Downloads the
322 # installer, copies it to the vm, then runs it before shutting down.
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
323 install_ie_win7() { # vm url md5
0a9b131 @xdissent Refactor
authored Jun 21, 2013
324 local src=`basename "${2}"`
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
325 local dest="C:\\Users\\${guest_user}\\Desktop\\${src}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
326
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
327 download "${src}" "${2}" "${src}" "${3}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
328 start_vm "${1}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
329 wait_for_guestcontrol "${1}"
330 copy_to_vm "${1}" "${src}" "${dest}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
331
332 log "Installing IE"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
333 guest_control_exec "${1}" "cmd.exe" /c \
334 "echo ${dest} /passive /norestart >C:\\Users\\${guest_user}\\ievms.bat"
335 guest_control_exec "${1}" "cmd.exe" /c \
336 "echo shutdown.exe /s /f /t 0 >>C:\\Users\\${guest_user}\\ievms.bat"
337 guest_control_exec "${1}" "schtasks.exe" /run /tn ievms
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
338
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
339 wait_for_shutdown "${1}"
340 }
341
342 # Build an ievms virtual machine given the IE version desired.
343 build_ievm() {
344 unset archive
345 unset unit
0416b6a @xdissent Add edge support
authored Aug 21, 2015
346 local prefix="IE"
347 local version="${1}"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
348 case $1 in
349 6|7|8)
350 os="WinXP"
351 if [ "${reuse_xp}" != "yes" ]
352 then
2e7e08c @xdissent Fix download args order.
authored Jun 21, 2013
353 if [ "$1" == "6" ]; then unit="10"; fi
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
354 if [ "$1" == "7" ]; then os="Vista"; fi
355 if [ "$1" == "8" ]; then os="Win7"; fi
356 else
357 archive="IE6_WinXP.zip"
358 unit="10"
359 fi
360 ;;
361 9) os="Win7" ;;
5c8aa72 @xdissent Add IE11 and bump version
authored Aug 16, 2013
362 10|11)
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
363 if [ "${reuse_win7}" != "yes" ]
364 then
5c8aa72 @xdissent Add IE11 and bump version
authored Aug 16, 2013
365 if [ "$1" == "11" ]; then fail "IE11 is only available if REUSE_WIN7 is set"; fi
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
366 os="Win8"
367 else
368 os="Win7"
369 archive="IE9_Win7.zip"
370 fi
371 ;;
0416b6a @xdissent Add edge support
authored Aug 21, 2015
372 EDGE)
373 prefix="MS"
374 version="Edge"
375 os="Win10"
376 unit="8"
377 ;;
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
378 *) fail "Invalid IE version: ${1}" ;;
379 esac
380
0416b6a @xdissent Add edge support
authored Aug 21, 2015
381 local vm="${prefix}${version} - ${os}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
382 local def_archive="${vm/ - /_}.zip"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
383 archive=${archive:-$def_archive}
384 unit=${unit:-"11"}
0a9b131 @xdissent Refactor
authored Jun 21, 2013
385 local ova=`basename "${archive/_/ - }" .zip`.ova
0416b6a @xdissent Add edge support
authored Aug 21, 2015
386
387 local url
388 if [ "${os}" == "Win10" ]
389 then
390 url="https://az792536.vo.msecnd.net/vms/VMBuild_20150801/VirtualBox/MSEdge/Mac/Microsoft%20Edge.Win10.For.Mac.VirtualBox.zip"
391 else
392 url="http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/${archive}"
393 fi
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
394
395 local md5
396 case $archive in
397 IE6_WinXP.zip) md5="3d5b7d980296d048de008d28305ca224" ;;
398 IE7_Vista.zip) md5="d5269b2220f5c7fb9786dad513f2c05a" ;;
399 IE8_Win7.zip) md5="21b0aad3d66dac7f88635aa2318a3a55" ;;
400 IE9_Win7.zip) md5="58d201fe7dc7e890ad645412264f2a2c" ;;
401 IE10_Win8.zip) md5="cc4e2f4b195e1b1e24e2ce6c7a6f149c" ;;
0416b6a @xdissent Add edge support
authored Aug 21, 2015
402 MSEdge_Win10.zip) md5="c1011b491d49539975fb4c3eeff16dae" ;;
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
403 esac
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
404
405 log "Checking for existing OVA at ${ievms_home}/${ova}"
406 if [[ ! -f "${ova}" ]]
407 then
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
408 download "OVA ZIP" "${url}" "${archive}" "${md5}"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
409
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
410 log "Extracting OVA from ${ievms_home}/${archive}"
0a9b131 @xdissent Refactor
authored Jun 21, 2013
411 unar "${archive}" || fail "Failed to extract ${archive} to ${ievms_home}/${ova}, unar command returned error code $?"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
412 fi
413
414 log "Checking for existing ${vm} VM"
415 if ! VBoxManage showvminfo "${vm}" >/dev/null 2>/dev/null
416 then
0a9b131 @xdissent Refactor
authored Jun 21, 2013
417 local disk_path="${ievms_home}/${vm}-disk1.vmdk"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
418 log "Creating ${vm} VM (disk: ${disk_path})"
419 VBoxManage import "${ova}" --vsys 0 --vmname "${vm}" --unit "${unit}" --disk "${disk_path}"
420
827286c @xdissent Update for VirtualBox 5.0
authored Aug 21, 2015
421 log "Adding shared folder"
422 VBoxManage sharedfolder add "${vm}" --automount --name ievms \
423 --hostpath "${ievms_home}"
424
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
425 log "Building ${vm} VM"
426 declare -F "build_ievm_ie${1}" && "build_ievm_ie${1}"
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
427
428 log "Tagging VM with ievms version"
429 VBoxManage setextradata "${vm}" "ievms" "{\"version\":\"${ievms_version}\"}"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
430
431 log "Creating clean snapshot"
432 VBoxManage snapshot "${vm}" take clean --description "The initial VM state"
433 fi
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
434 }
5c01014 @xdissent Add extra delay before clean snapshot for reused XP VMs to prevent sn…
authored Feb 4, 2013
435
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
436 # Build the IE6 virtual machine.
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
437 build_ievm_ie6() {
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
438 set_xp_password "IE6 - WinXP"
439 shutdown_xp "IE6 - WinXP"
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
440 }
441
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
442 # Build the IE7 virtual machine, reusing the XP VM if requested (the default).
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
443 build_ievm_ie7() {
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
444 if [ "${reuse_xp}" != "yes" ]
445 then
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
446 boot_auto_ga "IE7 - Vista"
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
447 else
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
448 set_xp_password "IE7 - WinXP"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
449 install_ie_xp "IE7 - WinXP" "http://download.microsoft.com/download/3/8/8/38889dc1-848c-4bf2-8335-86c573ad86d9/IE7-WindowsXP-x86-enu.exe" "ea16789f6fc1d2523f704e8f9afbe906"
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
450 fi
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
451 }
452
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
453 # Build the IE8 virtual machine, reusing the XP VM if requested (the default).
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
454 build_ievm_ie8() {
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
455 if [ "${reuse_xp}" != "yes" ]
456 then
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
457 boot_auto_ga "IE8 - Win7"
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
458 else
0c7e394 @xdissent Set the IEUser password for XP and normalize related commands
authored Nov 30, 2013
459 set_xp_password "IE8 - WinXP"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
460 install_ie_xp "IE8 - WinXP" "http://download.microsoft.com/download/C/C/0/CC0BD555-33DD-411E-936B-73AC6F95AE11/IE8-WindowsXP-x86-ENU.exe" "616c2e8b12aaa349cd3acb38bf581700"
44a7c12 @xdissent Add guest additions to non-XP IE7/8
authored Jun 12, 2013
461 fi
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
462 }
463
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
464 # Build the IE9 virtual machine.
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
465 build_ievm_ie9() {
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
466 boot_auto_ga "IE9 - Win7"
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
467 }
468
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
469 # Build the IE10 virtual machine, reusing the Win7 VM if requested (the default).
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
470 build_ievm_ie10() {
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
471 if [ "${reuse_win7}" != "yes" ]
472 then
473 boot_auto_ga "IE10 - Win8"
474 else
475 boot_auto_ga "IE10 - Win7"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
476 install_ie_win7 "IE10 - Win7" "http://download.microsoft.com/download/8/A/C/8AC7C482-BC74-492E-B978-7ED04900CEDE/IE10-Windows6.1-x86-en-us.exe" "0f14b2de0b3cef611b9c1424049e996b"
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
477 fi
4bb7cd5 @xdissent GA for all
authored Jun 12, 2013
478 }
479
5c8aa72 @xdissent Add IE11 and bump version
authored Aug 16, 2013
480 # Build the IE11 virtual machine, reusing the Win7 VM always.
481 build_ievm_ie11() {
482 boot_auto_ga "IE11 - Win7"
96546eb @xdissent Add md5sum checking
authored Jun 11, 2014
483 install_ie_win7 "IE11 - Win7" "http://download.microsoft.com/download/9/2/F/92FC119C-3BCD-476C-B425-038A39625558/IE11-Windows6.1-x86-en-us.exe" "7d3479b9007f3c0670940c1b10a3615f"
5c8aa72 @xdissent Add IE11 and bump version
authored Aug 16, 2013
484 }
485
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
486 # ## Main Entry Point
487
488 # Run through all checks to get the host ready for installation.
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
489 check_system
490 create_home
491 check_virtualbox
ebd97dc @xdissent Better checks for ext pack versions fixes #9 #27 #46 #57 #68 #71 #74 #77
authored Sep 23, 2012
492 check_ext_pack
21d759e @xdissent Use IE6 VM for IE7 and IE8 by default and use unar instead of unzip o…
authored Feb 3, 2013
493 check_unar
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
494
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
495 # Install each requested virtual machine sequentially.
0416b6a @xdissent Add edge support
authored Aug 21, 2015
496 all_versions="6 7 8 9 10 11 EDGE"
cacb5ae @xdissent Added IEVMS_VERSIONS environment variable support.
authored Aug 7, 2011
497 for ver in ${IEVMS_VERSIONS:-$all_versions}
498 do
0416b6a @xdissent Add edge support
authored Aug 21, 2015
499 log "Building IE ${ver} VM"
cacb5ae @xdissent Added IEVMS_VERSIONS environment variable support.
authored Aug 7, 2011
500 build_ievm $ver
501 done
cebd7c8 @xdissent Initial version (No IE6 support)
authored Aug 7, 2011
502
4d5e3d6 @xdissent Working on ie10 bs
authored Jun 20, 2013
503 # We made it!
5ca0fa0 @xdissent Remove unrar installation for Linux
authored Sep 7, 2011
504 log "Done!"
Something went wrong with that request. Please try again.