-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile.xenial
590 lines (524 loc) · 21.8 KB
/
Vagrantfile.xenial
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'fileutils'
require 'find'
require 'pathname'
require 'pp'
provision_selenium = ENV.fetch('PROVISION_SELENIUM', '')
selenium_version = ENV.fetch('SELENIUM_VERSION', '3.14.0')
#
chromedriver_version = ENV.fetch('CHROMEDRIVER_VERSION', '2.44')
firefox_version = ENV.fetch('FIREFOX_VERSION', '63.0.1')
geckodriver_version = ENV.fetch('GECKODRIVER_VERSION', '')
# experimental: install Katalon Studio for Linux
# NOTE: Katalon Studio requires that OpenJDK 8 - not the Oracle JDK - is installed
provision_katalon = ENV.fetch('PROVISION_KATALON', '') # empty for false
# Automatically download box into ~/Downloads. useful to upgrade base box
box_download = ENV.fetch('BOX_DOWNLOAD', false)
debug = ENV.fetch('DEBUG', false)
have_ssh_key = ENV.fetch('HAVE_SSH_KEY', false)
# Examine that specific Chrome version is available on https://www.slimjet.com/chrome/google-chrome-old-version.php
# TODO: embed the 'get_chrome_version.rb'
available_chrome_versions = %w|
104.0.5112.102
103.0.5060.53
102.0.5005.63
90.0.4430.72
86.0.4240.75
84.0.4147.135
83.0.4103.116
81.0.4044.92
80.0.3987.149
79.0.3945.88
78.0.3904.97
76.0.3809.100
75.0.3770.80
71.0.3578.80
70.0.3538.77
69.0.3497.92
68.0.3440.84
67.0.3396.79
66.0.3359.181
65.0.3325.181
64.0.3282.140
63.0.3239.108
62.0.3202.75
61.0.3163.79
60.0.3112.90
59.0.3071.86
58.0.3029.96
57.0.2987.133
56.0.2924.87
55.0.2883.75
54.0.2840.71
53.0.2785.116
52.0.2743.116
51.0.2704.84
50.0.2661.75
49.0.2623.75
48.0.2564.109
|
# TODO: add mnemonicts as oldest => -1, newest => 0
chrome_version = ENV.fetch('CHROME_VERSION', available_chrome_versions[0])
# chrome_version = ENV.fetch('CHROME_VERSION', available_chrome_versions[-1])
unless chrome_version.empty? or chrome_version =~ /(?:beta|stable|unstable)/ or available_chrome_versions.include?(chrome_version)
puts 'CHROME_VERSION should be set to "stable", "unstable" or "beta"'
puts "Specific old Chrome versions available from https://www.slimjet.com/chrome/google-chrome-old-version.php:\n" + available_chrome_versions.join("\n")
exit
end
VAGRANTFILE_API_VERSION = '2'
basedir = ENV.fetch('HOME','') || ENV.fetch('USERPROFILE', '')
box_memory = ENV.fetch('BOX_MEMORY', '2048').to_i
basedir = basedir.gsub('\\', '/')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if have_ssh_key
# https://www.vagrantup.com/docs/vagrantfile/ssh_settings.html
# see also
# https://riselab.ru/ustanovka-i-nastrojka-rabochej-sredy-homestead-dlya-laravel/
config.ssh.insert_key = false
end
config.vm.box = 'ubuntu/xenial64-fluxbox'
# Localy cached vagrant box image
version = '0.2.1'
config_vm_box_name = 'xenial-server-amd64-vagrant-selenium.box'
config.vm.box_url = "file://#{basedir}/Downloads/#{config_vm_box_name}"
box_download_url = "https://app.vagrantup.com/Th33x1l3/boxes/vagrant-selenium/versions/#{version}/providers/virtualbox.box"
box_filepath = config.vm.box_url.gsub(Regexp.new('^file://'),'')
box_filepath = config.vm.box_url.gsub(Regexp.new('^file://'),'')
if box_download
if File.exist?(box_filepath)
$stderr.puts (box_filepath + ' already downloaded. Remove the file to re-download')
else status = true
$stderr.puts "Downloading from #{box_download_url} to #{box_filepath}"
%x|curl -k -L #{box_download_url} -o #{box_filepath}|
end
end
# NOTE: vilnerable to time-consuming
# "intel_rapl: no valid rapl domains" message upon boot
# in inital Vagrant run
# https://askubuntu.com/questions/449574/intel-rapl-no-valid-rapl-domains-message-upon-boot
config.vm.network :forwarded_port, guest:4444, host:4444
config.vm.network :private_network, ip: '192.168.33.12'
config.vm.boot_timeout = 600
# NOTE: some Xenial images may have the following problem out of the box
# sudo: unable to resolve host ubuntu-xenial
# https://bugs.launchpad.net/ubuntu/+source/livecd-rootfs/+bug/1561250
# NOTE daily ubuntu xenial images have no vagrant user
# https://bugs.launchpad.net/cloud-images/+bug/1569237
config.vm.hostname = 'ubuntu-xenial64-fluxbox'
# gets cached in ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64-fluxbox/0/virtualbox
# Configure common synced folder
config.vm.synced_folder './' , '/vagrant'
config.vm.provision 'shell', inline: <<-SHELL
#!/bin/bash
#=========================================================
set -x
if ! grep -q $(cat /etc/hostname) /etc/hosts; then
echo 127.0.0.1 $(cat /etc/hostname) $(cat /etc/hostname) | more /etc/hosts
echo 127.0.1.1 vagrant | more /etc/hosts
echo 127.0.1.1 localhost | more /etc/hosts
fi
#=========================================================
# echo Clearing the proxy settings
sed -i 's/^/# /' /etc/apt/apt.conf.d/01proxy
sed -i '/[pP][rR][oO][xX][yY]/I d' /etc/environment
rm -f /etc/profile.d/proxy.sh
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
#=========================================================
echo Install the packages
# GPG servers aren't entirely reliable
declare -A key_hash=( ['keyserver.ubuntu.com']='1397BC53640DB551' ['keyserver.ubuntu.com']='6494C6D6997C215E' ['pgp.mit.edu']='6494C6D6997C215E')
for server in "${!key_hash[@]}"; do sudo apt-key adv --keyserver "${server}" --recv-keys "${key_hash[$server]}"; done
apt-get -qq update
apt-get -qqy install openjdk-8-jdk fluxbox xorg xserver-xorg-video-dummy xvfb unzip vim default-jre rungetty wget libxml2-utils jq
# NOTE: missing '/usr/share/images/fluxbox/ubuntu-light.png'
update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
#=========================================================
echo Set autologin for the vagrant user
mkdir -pv /etc/systemd/system/[email protected]/
cat <<EOF>/etc/systemd/system/[email protected]/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin vagrant --noclear %I 38400 linux
EOF
#=========================================================
cat <<EOF>> .profile
if [ ! -e '/tmp/.X0-lock' ] ; then
echo -n Start X on login
startx
else
echo X is alredy running..
fi
EOF
#=========================================================
PROVISION_SELENIUM='#{provision_selenium}'
if [[ $PROVISION_SELENIUM ]] ; then
echo Updating Selenium app stack
FIREFOX_VERSION='#{firefox_version}'
if [[ $FIREFOX_VERSION ]] ; then
echo Install Firefox version ${FIREFOX_VERSION}
cd /vagrant
PACKAGE_ARCHIVE="firefox-${FIREFOX_VERSION}.tar.bz2"
if [ ! -e $PACKAGE_ARCHIVE ] ; then
URL="https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/${PACKAGE_ARCHIVE}"
wget -O $PACKAGE_ARCHIVE -nv $URL
else
echo Using already downloaded archive $PACKAGE_ARCHIVE
fi
mkdir -p /home/vagrant/firefox
cd /home/vagrant
tar xjf "/vagrant/${PACKAGE_ARCHIVE}"
cp -R firefox /usr/lib
else
echo Install the latest Firefox
apt-get -qqy install firefox
fi
#=========================================================
SELENIUM_VERSION='#{selenium_version}'
SELENIM_RELEASE_URL='https://selenium-release.storage.googleapis.com/'
if [[ $SELENIUM_VERSION ]] ; then
echo Download specific Selenium version $SELENIUM_VERSION
SELENIUM_RELEASE=$(curl -s $SELENIM_RELEASE_URL | xmllint --xpath "//*[name() = 'Key'][contains(text(), 'selenium-server-standalone')][contains(text(), '${SELENIUM_VERSION}.jar')]/text()" - )
if [ -z $SELENIUM_RELEASE ] ; then
echo Invalid version
exit 1
else
echo "Selenium release: ${SELENIUM_RELEASE}"
fi
else
echo Download latest Selenium Server
SELENIUM_VERSION=$(curl -s $SELENIM_RELEASE_URL | xmllint --xpath "//*[local-name() = 'Key'][contains(text(), 'selenium-server-standalone')][contains(text(), '.jar')]" --shell - | sed -ne 's/<\\/*Key>/\\n/pg' | awk -F / '{print $1}' | sort -r -u -n -k1,1 -k2,2 -k3,3 -t. | head -1 )
echo "The latest Selenium Server version is ${SELENIUM_VERSION}"
fi
SELENIUM_RELEASE=$(curl -s $SELENIM_RELEASE_URL | xmllint --xpath "//*[name() = 'Key'][contains(text(), 'selenium-server-standalone')][contains(text(), '${SELENIUM_VERSION}.jar')]/text()" - )
PACKAGE_ARCHIVE="selenium-server-standalone-${SELENIUM_VERSION}.jar"
cd /vagrant
if [ ! -e $PACKAGE_ARCHIVE ] ; then
URL="https://selenium-release.storage.googleapis.com/${SELENIUM_RELEASE}"
echo Downloading Selenium $PACKAGE_ARCHIVE from $URL
wget -O $PACKAGE_ARCHIVE -nv $URL
else
echo Using already downloaded $PACKAGE_ARCHIVE
fi
cp $PACKAGE_ARCHIVE /home/vagrant/selenium-server-standalone.jar
cd /home/vagrant
chown vagrant:vagrant selenium-server-standalone.jar
#=========================================================
CHROME_VERSION='#{chrome_version}'
if [[ $CHROME_VERSION ]] ; then
echo installing libnss3
apt-get -qqy install --only-upgrade libnss3
case $CHROME_VERSION in
beta|stable|unstable)
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
apt-get install -qqy software-properties-common
apt-add-repository http://dl.google.com/linux/chrome/deb/
apt-get -qq update
apt-get install -qy --allow-unauthenticated google-chrome-${CHROME_VERSION}
;;
*)
apt-get remove -qqy -f google-chrome-stable
# TODO: fix trailing whitespace
apt-get -qqy install libxml2-utils
curl -s https://www.slimjet.com/chrome/google-chrome-old-version.php -o /tmp/a.html
echo 'Trying the new release format'
LATEST_CHROME_VERSION=$(xmllint --htmlout --html --xpath "//table[3]//tr/td/a[contains(@href,'file=files')]/@href" /tmp/a.html 2> /dev/null | sed 's|href="download-chrome.php?file=files%2F\\([0-9][0-9.]*\\)%2Fgoogle-chrome-stable_current_amd64.deb"|\\n\\1|gp;'| sort -r -u -n -k1,1 -k2,2 -k3,3 -t.| head -1 | awk '{print $1}')
LATEST_CHROME_RELEASE="files/${LATEST_CHROME_VERSION}/google-chrome-stable_current_amd64.deb"
PACKAGE_ARCHIVE="google-chrome-stable_current_amd64.deb"
if [ -z $LATEST_CHROME_VERSION ] ;then
echo 'Trying the old release format'
LATEST_CHROME_VERSION=$(xmllint --htmlout --html --xpath "//table[3]//tr/td/a[contains(@href,'file=lnx')]/@href" /tmp/a.html 2> /dev/null | sed 's|href="download-chrome.php?file=lnx%2Fchrome64_\\([0-9][0-9.]*\\).deb"|\\n\\1|gp;'| sort -r -u -n -k1,1 -k2,2 -k3,3 -t.| head -1 | awk '{print $1}')
LATEST_CHROME_RELEASE="lnx/chrome64_${LATEST_CHROME_VERSION}.deb"
PACKAGE_ARCHIVE="chrome64_${CHROME_VERSION}.deb"
fi
echo "Latest Chrome version available on slimjet: '${LATEST_CHROME_VERSION}'"
echo Installing Chrome version $CHROME_VERSION
export URL="http://www.slimjetbrowser.com/chrome/${LATEST_CHROME_RELEASE}"
cd /vagrant
if [ -e $PACKAGE_ARCHIVE ]
then
echo Using already downloaded archive $PACKAGE_ARCHIVE
else
echo Downloading Chrome from $URL
wget -nv $URL
fi
apt-get install -qqy libxss1 libappindicator1 libindicator7
dpkg -i $PACKAGE_ARCHIVE
# rm $PACKAGE_ARCHIVE
cd /home/vagrant
;;
esac
else
echo Download the latest Chrome
# http://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line
cd /tmp
wget -nv "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
apt-get install -qqy libxss1 libappindicator1 libindicator7
dpkg -i google-chrome-stable_current_amd64.deb
rm google-chrome-stable_current_amd64.deb
apt-get install -qqy -f google-chrome-stable
cd -
fi
#=========================================================
CHROMEDRIVER_VERSION='#{chromedriver_version}'
if [[ $CHROMEDRIVER_VERSION ]] ; then
echo "Download user specified version $CHROMEDRIVER_VERSION of Chromedriver"
else
echo Download latest Chromedriver
CHROMEDRIVER_VERSION=$(curl -s "http://chromedriver.storage.googleapis.com/LATEST_RELEASE")
# alternatively
CHROMEDRIVER_VERSION=$(curl -s -k https://chromedriver.storage.googleapis.com/ | xmllint --xpath '//*[local-name()="Contents"]/*[local-name()="Key"]' - | sed 's/<\\/*Key>/\\n/g' | sed -n 's/\\([0-9]\\.[0-9][0-9]*\\)\\/chromedriver_linux64.zip/\\1/p' | sort -V -r | head -1)
# NOTE: the intermediate xmllint output in the above is not a valid XML
# NOTE: alternatively
# | sort -t. -n -k1,1 -k2,2
fi
PACKAGE_ARCHIVE='chromedriver_linux64.zip'
cd /vagrant
if [ ! -e $PACKAGE_ARCHIVE ]; then
URL="http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
wget -O $PACKAGE_ARCHIVE -nv $URL
fi
cd /home/vagrant
unzip -o "/vagrant/${PACKAGE_ARCHIVE}"
chown vagrant:vagrant chromedriver
echo Installed Chrome Driver version $(./chromedriver --version| head -1 | cut -f 2 -d ' ')
echo Done
#=========================================================
GECKODRIVER_VERSION='#{geckodriver_version}'
if [[ $GECKODRIVER_VERSION ]] ; then
echo "Download the user specified version ${GECKODRIVER_VERSION} of Geckodriver."
else
echo Determine the latest version of GeckoDriver
GECKO_RELEASE_URL='https://api.github.com/repos/mozilla/geckodriver/releases'
# https://stedolan.github.io/jq/manual/#ConditionalsandComparisons
# https://github.com/stedolan/jq/issues/370
echo Processing list of GeckoDriver releases...
# uncomment next line for debugging
# curl -s -k $GECKO_RELEASE_URL | jq '.[] | .assets[] | .browser_download_url' | grep -v 'wires' | grep 'linux64' | sed 's/^.*\\///'
GECKODRIVER_VERSION=$(curl -s -k $GECKO_RELEASE_URL | jq '.[] | .assets[] | .browser_download_url' | grep -v 'wires' | grep 'linux64' | sed 's/^.*\\///' | cut -f2 -d'-' | cut -f2,2,4 -d'.'| sort -rn | head -1 )
GECKODRIVER_RELEASE=$(curl -s -k $GECKO_RELEASE_URL | jq '.[] | .assets[] | .browser_download_url' | grep -v 'wires' | grep 'linux64' | sed 's/^.*download\\///' | grep "$GECKODRIVER_VERSION" | tr -d '"')
fi
URL="https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_RELEASE}"
ARCHIVE='/var/tmp/geckodriver_linux64.tar.gz'
echo Downloading GECKODRIVER version $GECKODRIVER_VERSION from $URL
wget -O $ARCHIVE -nv $URL
cd /home/vagrant
tar -xzf $ARCHIVE
chown vagrant:vagrant geckodriver
echo Installed Gecko Driver version $(./geckodriver --version | head -1 | cut -f 2 -d ' ')
# TODO: geckodriver ERROR Address in use (os error 98)
#=========================================================
fi
#=========================================================
echo create and populate the .fluxbox directory.
# cp /vagrant/fluxbox.tar.gz /home/vagrant
# pushd /home/vagrant
# tar xzvf fluxbox.tar.gz
pushd /home/vagrant
mkdir -p .fluxbox/backgrounds .fluxbox/pixmaps .fluxbox/styles
cat <<EOF > .fluxbox/apps
[app] (name=fbrun)
[Position] (WINCENTER) {0 0}
[Layer] {2}
[end]
EOF
touch .fluxbox/fbrun_history
cat <<EOF > .fluxbox/init
! If you're looking for settings to configure, they won't be saved here until
! you change something in the fluxbox configuration menu.
session.menuFile: ~/.fluxbox/menu
session.keyFile: ~/.fluxbox/keys
session.styleFile: /usr/share/fluxbox/styles//ubuntu-light
session.configVersion: 13
session.screen0.toolbar.widthPercent: 100
session.screen0.strftimeFormat: %d %b, %a %02k:%M:%S
session.screen0.toolbar.tools: prevworkspace, workspacename, nextworkspace, clock, prevwindow, nextwindow, iconbar, systemtray
EOF
cat <<EOF > .fluxbox/keys
# click on the desktop to get menus
OnDesktop Mouse1 :HideMenus
OnDesktop Mouse2 :WorkspaceMenu
OnDesktop Mouse3 :RootMenu
# scroll on the desktop to change workspaces
OnDesktop Mouse4 :PrevWorkspace
OnDesktop Mouse5 :NextWorkspace
# scroll on the toolbar to change current window
OnToolbar Mouse4 :PrevWindow {static groups} (iconhidden=no)
OnToolbar Mouse5 :NextWindow {static groups} (iconhidden=no)
# alt + left/right click to move/resize a window
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindowBorder Move1 :StartMoving
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}
OnLeftGrip Move1 :StartResizing bottomleft
OnRightGrip Move1 :StartResizing bottomright
# alt + middle click to lower the window
OnWindow Mod1 Mouse2 :Lower
# control-click a window's titlebar and drag to attach windows
OnTitlebar Control Mouse1 :StartTabbing
# double click on the titlebar to shade
OnTitlebar Double Mouse1 :Shade
# left click on the titlebar to move the window
OnTitlebar Mouse1 :MacroCmd {Raise} {Focus} {ActivateTab}
OnTitlebar Move1 :StartMoving
# middle click on the titlebar to lower
OnTitlebar Mouse2 :Lower
# right click on the titlebar for a menu of options
OnTitlebar Mouse3 :WindowMenu
# alt-tab
Mod1 Tab :NextWindow {groups} (workspace=[current])
Mod1 Shift Tab :PrevWindow {groups} (workspace=[current])
# cycle through tabs in the current window
Mod4 Tab :NextTab
Mod4 Shift Tab :PrevTab
# go to a specific tab in the current window
Mod4 1 :Tab 1
Mod4 2 :Tab 2
Mod4 3 :Tab 3
Mod4 4 :Tab 4
Mod4 5 :Tab 5
Mod4 6 :Tab 6
Mod4 7 :Tab 7
Mod4 8 :Tab 8
Mod4 9 :Tab 9
# open a terminal
Mod1 F1 :Exec x-terminal-emulator
# open a dialog to run programs
Mod1 F2 :Exec fbrun
# volume settings, using common keycodes
# if these don't work, use xev to find out your real keycodes
176 :Exec amixer sset Master,0 1+
174 :Exec amixer sset Master,0 1-
160 :Exec amixer sset Master,0 toggle
# current window commands
Mod1 F4 :Close
Mod1 F5 :Kill
Mod1 F9 :Minimize
Mod1 F10 :Maximize
Mod1 F11 :Fullscreen
# open the window menu
Mod1 space :WindowMenu
# exit fluxbox
Control Mod1 Delete :Exit
# change to previous/next workspace
Control Mod1 Left :PrevWorkspace
Control Mod1 Right :NextWorkspace
# send the current window to previous/next workspace
Mod4 Left :SendToPrevWorkspace
Mod4 Right :SendToNextWorkspace
# send the current window and follow it to previous/next workspace
Control Mod4 Left :TakeToPrevWorkspace
Control Mod4 Right :TakeToNextWorkspace
# change to a specific workspace
Control F1 :Workspace 1
Control F2 :Workspace 2
Control F3 :Workspace 3
Control F4 :Workspace 4
# send the current window to a specific workspace
Mod4 F1 :SendToWorkspace 1
Mod4 F2 :SendToWorkspace 2
Mod4 F3 :SendToWorkspace 3
Mod4 F4 :SendToWorkspace 4
# send the current window and change to a specific workspace
Control Mod4 F1 :TakeToWorkspace 1
Control Mod4 F2 :TakeToWorkspace 2
Control Mod4 F3 :TakeToWorkspace 3
Control Mod4 F4 :TakeToWorkspace 4
EOF
touch .fluxbox/lastwallpaper
cat <<EOF > .fluxbox/menu
[begin] (fluxbox)
[include] (/etc/X11/fluxbox/fluxbox-menu)
[end]
EOF
touch .fluxbox/overlay
cat <<EOF > .fluxbox/startup
#!/bin/sh
#
# vanilla fluxbox startup-script:
#
# Lines starting with a '#' are ignored.
# Change your keymap:
xmodmap "/home/vagrant/.Xmodmap"
# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
# idesk &
#
# Debian-local change:
# - fbautostart has been added with a quick hack to check to see if it
# exists. If it does, we'll start it up by default.
which fbautostart > /dev/null
if [ $? -eq 0 ]; then
fbautostart
fi
# And last but not least we start fluxbox.
# Because it is the last app you have to run it with ''exec'' before it.
exec fluxbox
# or if you want to keep a log:
# exec fluxbox -log "/home/vagrant/.fluxbox/log"
# Set screen resolution
xrandr -s 1280x800
EOF
cat <<EOF > .fluxbox/windowmenu
[begin]
[shade]
[stick]
[maximize]
[iconify]
[raise]
[lower]
[settitledialog]
[sendto]
[layer]
[alpha]
[extramenus]
[separator]
[close]
[end]
EOF
#=========================================================
#=========================================================
echo Install tmux scripts
cat <<EOF> tmux.sh
#!/bin/sh
if \\$(netstat -lp 2> /dev/null| grep -q X) ; then
echo 'X already started'
else
tmux start-server
fi
tmux new-session -d -s chrome-driver
tmux send-keys -t chrome-driver:0 'export DISPLAY=:0' C-m
tmux send-keys -t chrome-driver:0 './chromedriver' C-m
tmux new-session -d -s selenium
tmux send-keys -t selenium:0 '/usr/bin/xrandr -s 1280x800' C-m
tmux send-keys -t selenium:0 'export DISPLAY=:0' C-m
# NOTE options for java runtime.
tmux send-keys -t selenium:0 'java -Xmn512M -Xms1G -Xmx1G -jar selenium-server-standalone.jar' C-m
tmux send-keys -t selenium:0 'for cnt in {0..10}; do wget -O- http://127.0.0.1:4444/wd/hub; sleep 120; done' C-m
EOF
chmod +x tmux.sh
chown vagrant:vagrant tmux.sh
#=========================================================
echo Install startup scripts
cat <<EOF> /etc/X11/Xsession.d/9999-common_start
#!/bin/sh
/home/vagrant/tmux.sh &
xterm -fa fixed &
EOF
chmod +x /etc/X11/Xsession.d/9999-common_start
#=========================================================
echo -n 'Add host alias'
echo '192.168.33.1 host'| tee -a /etc/hosts
#=========================================================
echo Reboot the VM
sudo reboot
SHELL
config.vm.provider :virtualbox do |v|
v.gui = true
v.name = 'Selenium Fluxbox Xenial'
v.customize ['modifyvm', :id, '--memory', box_memory, '--vram', '16', '--ioapic', 'on', '--cableconnected1', 'on', '--clipboard', 'bidirectional']
v.customize ['setextradata', 'global', 'GUI/MaxGuestResolution', 'any']
v.customize ['setextradata', :id, 'CustomVideoMode1', '1280x800x32']
# the following command requires Virtalbox Guest Additions to be installed i the box, currently it is not the csase with xenial base box we are using
# VBoxManage controlvm 'Selenium Fluxbox Trusty' setvideomodehint 1280 800 32
end
end