blob: dd49b96b5f617529411e957ad8b025e3b280f1e6 (
plain)
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
|
#!/usr/bin/env bash
help() {
cat <<'EOT'
Install Script for Virtualbox and PHPVirtualbox (apt-based distros)
-v --virtualbox-only Install and/or configure Virtualbox
-p --phpvirtualbox-only Install PHPVirtualbox
-a --all Install both Virtualbox and PHPVirtualbox
--install-extpack Download and install the Oracle Extension Pack
--accept-extpack-license Accept Oracle License to install Extension Pack
--phpvirtualbox-version= PHPVirtualbox version to download and install
--install-dir= Directory to install PHPVirtualbox
--vbox-user= User to run Virtualbox (created if missing)
-d= --debug= Debug output 0=quiet, 10=verbose
EOT
}
# Sensible defaults
DEBUG=0
#Disable visual prompting during upgrades
DEBIAN_FRONTEND=noninteractive
INSTALL_VBOX=${INSTALL_VBOX:=true}
INSTALL_PHPVBOX=${INSTALL_PHPVBOX:=true}
INSTALL_EXTPACK=${INSTALL_EXTPACK:=false}
PHPVBOX_INSTALL_DIR=${PHPVBOX_INSTALL_DIR:='/usr/share/phpvirtualbox'}
PHPVBOX_VERSION=${PHPVBOX_VERSION:='latest'}
APT=${APT:='apt-get -y'}
APT_KEY=${APT_KEY:='apt-key'}
ACCEPT_ORACLE_EXTPACK_LICENSE=${ACCEPT_ORACLE_EXTPACK_LICENSE:='n'}
VBOX_USER=${VBOX_USER:='vbox'}
VBOX_GROUP=${VBOX_GROUP:='vboxusers'}
VBOX_HOME=${VBOX_HOME:="/home/${VBOX_USER}"}
VBOX_VM_DIR=${VBOX_VM_DIR:="${VBOX_HOME}/VBox/VMs"}
VBOX_DRIVES_DIR=${VBOX_DRIVES_DIR:="${VBOX_HOME}/VBox/drives"}
VBOX_IMPORT_DIR=${VBOX_IMPORT_DIR:="${VBOX_HOME}/VBox/import"}
VBOX_AUTOSTART_DIR=${VBOX_AUTOSTART_DIR:="${VBOX_HOME}/VBoxAutostart"}
VBOX_ETC_DEFAULT=${VBOX_ETC_DEFAULT:='/etc/default/virtualbox'}
AUTOSTART_CONF=${AUTOSTART_CONF:='/etc/vbox/autostart.conf'}
WAIT_FOR_STOP=10s
for i in "$@"
do
case $i in
-d=*|--debug=*)
DEBUG="${i#*=}"
;;
--install-dir=*)
PHPVBOX_INSTALL_DIR="${i#*=}"
;;
--virtualbox-user=*)
VBOX_USER="${i#*=}"
;;
--virtualbox-group=*)
VBOX_GROUP="${i#*=}"
;;
-v|--virtualbox-only)
INSTALL_VBOX=true
INSTALL_PHPVBOX=false
;;
-p|--phpvirtualbox-only)
INSTALL_VBOX=false
INSTALL_PHPVBOX=true
;;
--phpvirtualbox-version=*)
PHPVBOX_VERSION="${i#*=}"
;;
--install-extpack)
INSTALL_EXTPACK=true
;;
--accept-extpack-license)
INSTALL_EXTPACK=true
ACCEPT_ORACLE_EXTPACK_LICENSE='y'
;;
-a|--all)
INSTALL_VBOX=true
INSTALL_PHPVBOX=true
;;
-h|--help)
help
exit 0
;;
*)
# unknown option
;;
esac
done
## Check we're running as root so we don't need to rely on sudo.
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
########################
## INSTALL VIRTUALBOX ##
########################
if [ "${INSTALL_VBOX}" = true ]; then
# Virtualbox Version needs to match PHPVirtualBox version
# unless pulling from "develop" or "master"
if [ "${PHPVBOX_VERSION}" == 'latest' ]; then
RELEASE_TAG_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/phpvirtualbox/phpvirtualbox/releases/latest)
PHPVBOX_VERSION=$(echo $RELEASE_TAG_URL | awk -F/ '{print $8}')
fi
if [ "${PHPVBOX_VERSION}" == "development" ]; then
VIRTUALBOX_VERSION=$(wget -O- https://raw.githubusercontent.com/phpvirtualbox/phpvirtualbox/develop/endpoints/lib/config.php | grep "define('PHPVBOX_VER'" | sed -n "s/^.*\([0-9]\+\.[0-9]\+\).*$/\1/p")
else
VIRTUALBOX_VERSION=`echo "$PHPVBOX_VERSION" | sed -n "s/^\([0-9]\+\.[0-9]\+\).*$/\1/p"`
fi
if [[ $VIRTUALBOX_VERSION =~ ^[0-9]+.[0-9]+$ ]]; then
cat << EOT
###############################
## INSTALLING VIRTUALBOX $VIRTUALBOX_VERSION ##
###############################
EOT
else
echo "ERROR: UNKNOWN VIRTUALBOX VERSION: $VIRTUALBOX_VERSION"
exit -1
fi
set -u
set -e
set -o pipefail
echo ">>>> Importing Oracle Virtualbox Debian Repository key <<<<"
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | ${APT_KEY} add -
echo ">>>> Adding Oracle Virtualbox Debian Repository <<<<"
echo -e "## Virtualbox\ndeb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | tee /etc/apt/sources.list.d/virtualbox.list >/dev/null
echo ">>>> Updating Oracle Virtualbox Debian Repository index <<<<"
${APT} update
echo ">>>> Installing build-essential pwgen and curl <<<<"
${APT} install build-essential pwgen curl
echo ">>>> Stop vbox services <<<<"
systemctl --no-pager stop vboxdrv.service vboxautostart-service.service vboxweb-service.service || true
echo ">>>> Waiting $WAIT_FOR_STOP until all services shut down <<<<"
sleep "$WAIT_FOR_STOP"
echo ">>>> Installing VirtualBox on non-x11 system <<<<"
${APT} install --reinstall virtualbox-${VIRTUALBOX_VERSION} --no-install-recommends
echo ">>>> Adding vbox user <<<<"
adduser --disabled-password --gecos "VirtualBox" vbox || true
echo ">>>> Setting password for vbox user <<<<"
pw=$(pwgen -s 30 1)
echo -e "${pw}\n${pw}\n" | passwd vbox >/dev/null
echo "$pw" | tee /root/vbox.user.password >/dev/null
chmod og-rwx /root/vbox.user.password
echo ">>>> Adding ${VBOX_USER} user to ${VBOX_GROUP} group <<<<"
adduser ${VBOX_USER} ${VBOX_GROUP}
echo ">>>> Adding ${VBOX_USER} user to cdrom group <<<<"
adduser ${VBOX_USER} cdrom
echo ">>>> Creating '${VBOX_VM_DIR}' <<<<"
su ${VBOX_USER} -c "mkdir -p \"${VBOX_VM_DIR}\""
echo ">>>> Creating '${VBOX_DRIVES_DIR}' <<<<"
su ${VBOX_USER} -c "mkdir -p \"${VBOX_DRIVES_DIR}\""
echo ">>>> Creating '${VBOX_IMPORT_DIR}' <<<<"
su ${VBOX_USER} -c "mkdir -p \"${VBOX_IMPORT_DIR}\""
echo ">>>> Setting '${VBOX_VM_DIR}' as default machine folder for user vbox <<<<"
su ${VBOX_USER} -c "vboxmanage setproperty machinefolder \"${VBOX_VM_DIR}\""
echo ">>>> Removing any previous VBox Extension Pack <<<<"
vboxmanage extpack uninstall "Oracle VM VirtualBox Extension Pack"
if [ "${INSTALL_EXTPACK}" = true ]; then
echo ">>>> Installing latest VBox Extension Pack <<<<"
cd /tmp
version=$(wget -qO- https://download.virtualbox.org/virtualbox/LATEST.TXT)
wget -c "https://download.virtualbox.org/virtualbox/${version}/Oracle_VM_VirtualBox_Extension_Pack-${version}.vbox-extpack"
echo ${ACCEPT_ORACLE_EXTPACK_LICENSE} | vboxmanage extpack install "Oracle_VM_VirtualBox_Extension_Pack-${version}.vbox-extpack"
rm "Oracle_VM_VirtualBox_Extension_Pack-${version}.vbox-extpack"
cd -
fi
echo ">>>> Creating '${AUTOSTART_CONF}' <<<<"
echo -e "default_policy = deny\nvbox = {\n allow = true\n}" | tee "$AUTOSTART_CONF" >/dev/null
echo ">>>> Creating '${VBOX_AUTOSTART_DIR}' <<<<"
su ${VBOX_USER} -c "mkdir -p \"${VBOX_AUTOSTART_DIR}\""
su ${VBOX_USER} -c "chmod g+w \"${VBOX_AUTOSTART_DIR}\""
# set sticky bit
su ${VBOX_USER} -c "chmod +t \"${VBOX_AUTOSTART_DIR}\""
su ${VBOX_USER} -c "vboxmanage setproperty autostartdbpath \"${VBOX_AUTOSTART_DIR}\""
echo ">>>> Removing old autostart config from '${VBOX_ETC_DEFAULT}' <<<<"
touch "$VBOX_ETC_DEFAULT"
sed -i -e "/^\s*VBOXAUTOSTART_DB\s*=.*$/d" "$VBOX_ETC_DEFAULT"
sed -i -e "/^\s*VBOXAUTOSTART_CONFIG\s*=.*$/d" "$VBOX_ETC_DEFAULT"
echo ">>>> Appending new autostart config to '${VBOX_ETC_DEFAULT}' <<<<"
echo -e "VBOXAUTOSTART_DB=${VBOX_AUTOSTART_DIR}\nVBOXAUTOSTART_CONFIG=/etc/vbox/autostart.conf" | tee -a "$VBOX_ETC_DEFAULT" >/dev/null
echo ">>>> Restarting vbox services <<<<"
systemctl --no-pager status vboxdrv.service
systemctl --no-pager restart vboxdrv.service
systemctl --no-pager status vboxdrv.service
echo ">>>> Restarting vbox services <<<<"
systemctl --no-pager status vboxautostart-service.service
systemctl --no-pager restart vboxautostart-service.service
systemctl --no-pager status vboxautostart-service.service
echo ">>>> Creating '${VBOX_HOME}/bin' <<<<"
su ${VBOX_USER} -c "mkdir -p \"${VBOX_HOME}/bin\""
echo ">>>> Creating '${VBOX_HOME}/bin/vbox_save_rvms.bash' <<<<"
set +e
read -r -d '' vbox_save_rvms_bash_content <<'EOF'
#!/usr/bin/env bash
set -u
set -e
set -o pipefail
svm="$HOME/saved_vms"
echo -n "" >"$svm"
vboxmanage list runningvms | cut -d'"' -f3 | cut -d" " -f2 | while read uid; do
echo "Saving state of $uid ..."
vboxmanage controlvm "$uid" savestate
echo "DONE"
echo "$uid" >>"$svm"
done
chmod og-rwx "$svm"
EOF
read_exit_val=$?
set -e
if [ $read_exit_val != 1 ]; then
exit $read_exit_val
fi
echo "$vbox_save_rvms_bash_content" | su ${VBOX_USER} -c "tee \"${VBOX_HOME}/bin/vbox_save_rvms.bash\" >/dev/null"
echo ">>>> Making '${VBOX_HOME}/bin/vbox_save_rvms.bash' executable <<<<"
su ${VBOX_USER} -c "chmod +x \"${VBOX_HOME}/bin/vbox_save_rvms.bash\""
echo ">>>> Creating '${VBOX_HOME}/bin/vbox_start_svms.bash' <<<<"
set +e
read -r -d '' vbox_start_svms_bash_content <<'EOF'
#!/usr/bin/env bash
set -u
set -e
set -o pipefail
svm="$HOME/saved_vms"
if [ ! -f "$svm" ]; then
exit 0
fi
vms=$(vboxmanage list vms)
svms=$(cat "$svm")
for uid in $svms; do
echo "Trying to start VM $uid"
if [ $( echo "$vms" | grep "$uid" | wc -l ) == 0 ]; then
echo "Found no VM $uid, skipping"
continue
else
echo "Found VM $uid"
fi
echo "Starting VM $uid in headless mode..."
vboxmanage startvm "$uid" --type headless
echo "DONE"
echo "Removing VM $uid from autostart"
tmp_file=$(mktemp)
grep -v "$uid" "$svm" >"$tmp_file" || true
mv -f "$tmp_file" "$svm"
echo "DONE"
done
EOF
read_exit_val=$?
set -e
if [ $read_exit_val != 1 ]; then
exit $read_exit_val
fi
echo "$vbox_start_svms_bash_content" | su ${VBOX_USER} -c "tee \"${VBOX_HOME}/bin/vbox_start_svms.bash\" >/dev/null"
echo ">>>> Making '${VBOX_HOME}/bin/vbox_start_svms.bash' executable <<<<"
su ${VBOX_USER} -c "chmod +x \"${VBOX_HOME}/bin/vbox_start_svms.bash\""
echo ">>>> Creating '${VBOX_HOME}/bin/vbox_activate_auto.bash' <<<<"
set +e
read -r -d '' vbox_activate_auto_bash_content <<'EOF'
#!/usr/bin/env bash
set -u
set -e
set -o pipefail
rvms=$(vboxmanage list runningvms)
vms=$(vboxmanage list vms)
function activate_auto() {
if [ $( echo "$rvms" | grep "$1" | wc -l ) != 0 ]; then
echo "VM $1 is running, skipping"
continue
fi
if [ $( echo "$vms" | grep "$1" | wc -l ) == 0 ]; then
echo "Found no VM $1, skipping"
continue
fi
echo "Enabling autostart for VM $1 ..."
vboxmanage modifyvm "$1" --autostart-enabled on
echo "Enabling autostop (savestate) for VM $1 ..."
vboxmanage modifyvm "$1" --autostop-type savestate
}
if [[ $# -eq 0 ]]; then
echo "$vms" | cut -d'"' -f3 | cut -d" " -f2 | while read uid; do
activate_auto "$uid"
done
else
while [ $# -gt 0 ]; do
activate_auto "$1"
shift
done
fi
EOF
read_exit_val=$?
set -e
if [ $read_exit_val != 1 ]; then
exit $read_exit_val
fi
echo "$vbox_activate_auto_bash_content" | su ${VBOX_USER} -c "tee \"${VBOX_HOME}/bin/vbox_activate_auto.bash\" >/dev/null"
echo ">>>> Making '${VBOX_HOME}/bin/vbox_activate_auto.bash' executable <<<<"
su ${VBOX_USER} -c "chmod +x \"${VBOX_HOME}/bin/vbox_activate_auto.bash\""
echo ">>>> Creating '${VBOX_HOME}/bin/vbox_deactivate_auto.bash' <<<<"
set +e
read -r -d '' vbox_deactivate_auto_bash_content <<'EOF'
#!/usr/bin/env bash
set -u
set -e
set -o pipefail
rvms=$(vboxmanage list runningvms)
vms=$(vboxmanage list vms)
function deactivate_auto() {
if [ $( echo "$rvms" | grep "$1" | wc -l ) != 0 ]; then
echo "VM $1 is running, skipping"
continue
fi
if [ $( echo "$vms" | grep "$1" | wc -l ) == 0 ]; then
echo "Found no VM $1, skipping"
continue
fi
echo "Disabeling autostart for VM $1 ..."
vboxmanage modifyvm "$1" --autostart-enabled off
}
if [[ $# -eq 0 ]]; then
echo "$vms" | cut -d'"' -f3 | cut -d" " -f2 | while read uid; do
deactivate_auto "$uid"
done
else
while [ $# -gt 0 ]; do
deactivate_auto "$1"
shift
done
fi
EOF
read_exit_val=$?
set -e
if [ $read_exit_val != 1 ]; then
exit $read_exit_val
fi
echo "$vbox_deactivate_auto_bash_content" | su ${VBOX_USER} -c "tee \"${VBOX_HOME}/bin/vbox_deactivate_auto.bash\" >/dev/null"
echo ">>>> Making '${VBOX_HOME}/bin/vbox_deactivate_auto.bash' executable <<<<"
su ${VBOX_USER} -c "chmod +x \"${VBOX_HOME}/bin/vbox_deactivate_auto.bash\""
fi
###########################
## INSTALL PHPVIRTUALBOX ##
###########################
if [ "${INSTALL_PHPVBOX}" = true ]; then
cat << EOT
##############################
## INSTALLING PHPVIRTUALBOX ##
##############################
EOT
set -u
set -e
set -o pipefail
echo ">>>> Setting websrvauthlibrary <<<<"
VBoxManage setproperty websrvauthlibrary null
echo ">>>> Removing old vboxweb config from '${VBOX_ETC_DEFAULT}' <<<<"
touch "${VBOX_ETC_DEFAULT}"
sed -i -e "/^\s*VBOXWEB_USER\s*=.*$/d" "${VBOX_ETC_DEFAULT}"
echo ">>>> Appending new vboxweb config to '${VBOX_ETC_DEFAULT}' <<<<"
echo "VBOXWEB_USER=vbox" | tee -a ${VBOX_ETC_DEFAULT} >/dev/null
hname=$(hostname)
# remove leading whitespace characters
hname="${hname#"${hname%%[![:space:]]*}"}"
# remove trailing whitespace characters
hname="${hname%"${hname##*[![:space:]]}"}"
fqdn=$(hostname -A)
# remove leading whitespace characters
fqdn="${fqdn#"${fqdn%%[![:space:]]*}"}"
# remove trailing whitespace characters
fqdn="${fqdn%"${fqdn##*[![:space:]]}"}"
echo ">>>> Removing previous ${PHPVBOX_INSTALL_DIR} <<<<"
rm -rf "${PHPVBOX_INSTALL_DIR}"
echo ">>>> Creating ${PHPVBOX_INSTALL_DIR} <<<<"
mkdir "${PHPVBOX_INSTALL_DIR}"
echo ">>>> Owning by ${VBOX_GROUP} <<<<"
chgrp ${VBOX_GROUP} "${PHPVBOX_INSTALL_DIR}"
echo ">>>> Cloning phpvirtualbox <<<<"
if [ "${PHPVBOX_VERSION}" == "development" ]; then
git clone https://github.com/phpvirtualbox/phpvirtualbox.git "${PHPVBOX_INSTALL_DIR}"
chgrp -R ${VBOX_GROUP} "${PHPVBOX_INSTALL_DIR}"
cd "${PHPVBOX_INSTALL_DIR}"
echo ">>>> Using develop branch <<<<"
git checkout develop
else
if [ "${PHPVBOX_VERSION}" == 'latest' ]; then
RELEASE_TAG_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/phpvirtualbox/phpvirtualbox/releases/latest)
PHPVBOX_VERSION=$(echo $RELEASE_TAG_URL | awk -F/ '{print $8}')
fi
cd /tmp
wget -c https://github.com/phpvirtualbox/phpvirtualbox/archive/${PHPVBOX_VERSION}.tar.gz
mkdir -p "${PHPVBOX_INSTALL_DIR}"
chgrp ${VBOX_GROUP} "${PHPVBOX_INSTALL_DIR}"
cd "${PHPVBOX_INSTALL_DIR}"
tar -xzvf /tmp/${PHPVBOX_VERSION}.tar.gz --strip-components=1
cd -
fi
if [ "${PHPVBOX_INSTALL_DIR}" != "/usr/share/phpvirtualbox" ]; then
echo ">>>> Changing path to ${PHPVBOX_INSTALL_DIR} in phpvirtualbox.conf <<<<"
REPLACE=$(echo ${PHPVBOX_INSTALL_DIR} | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/\/usr\/share\/phpvirtualbox/$REPLACE/g" phpvirtualbox.conf
fi
#echo ">>>> Allowing connections from anywhere in phpvirtualbox.conf <<<<"
#sed -i -e "s/^\(\s*\)Require local$/\1#Require local\n\1# Allow connections from anywhere:\nRequire all granted/g" phpvirtualbox.conf
#echo ">>>> Changing alias in phpvirtualbox.conf <<<<"
#sed -i -e "s/Alias \/phpvirtualbox\S*/Alias \/phpvirtualbox.${hname}/g" phpvirtualbox.conf
#dpkg -s apache2 php7.0 libapache2-mod-php7.0 >/dev/null 2>&1
#if [ $? -ne 0 ]; then
# echo "Dependency is missing:"
# apt-cache policy apache2 php7.0 libapache2-mod-php7.0 | grep -B1 Installed
# exit 1
#fi
echo ">>>> Installing apache, php, etc <<<<"
${APT} install apache2 php libapache2-mod-php php-soap php-xml
echo ">>>> Installing apache alias <<<<"
cp ${PHPVBOX_INSTALL_DIR}/phpvirtualbox.conf /etc/apache2/conf-available/
echo ">>>> Enabling Apache alias <<<<"
a2enconf phpvirtualbox
echo ">>>> Reloading Apache config <<<<"
systemctl --no-pager reload apache2
echo ">>>> Creating phpVirtualbox config <<<<"
if [ ! -f /root/vbox.user.password ]; then
echo "Dependency is missing: /root/vbox.user.password"
exit 1
fi
cp ${PHPVBOX_INSTALL_DIR}/config.php-example ${PHPVBOX_INSTALL_DIR}/config.php
echo ">>>> Setting user and password in phpVirtualbox config <<<<"
sed -i -e 's/^var $username = .*$/var $username = '"'vbox'"';/g' ${PHPVBOX_INSTALL_DIR}/config.php
pw=$(cat /root/vbox.user.password)
sed -i -e 's/^var $password = .*$/var $password = '"'${pw}'"';/g' ${PHPVBOX_INSTALL_DIR}/config.php
echo ">>>> Setting site name in phpVirtualbox config <<<<"
sed -i -e 's/^\(var $location = .*\)$/\1\nvar $name = '"'${fqdn}'"';/g' ${PHPVBOX_INSTALL_DIR}/config.php
echo ">>>> Setting folder restrictions in phpVirtualbox config <<<<"
sed -i -e 's/^\s*#*\s*\(var $browserRestrictFolders\)\s*=\s*.*$/\1 = array('"'\/home\/vbox\/VBox'"');/g' ${PHPVBOX_INSTALL_DIR}/config.php
echo ">>>> Enabling advanced vm config in phpVirtualbox config <<<<"
sed -i -e 's/^\s*#*\s*\(var $enableAdvancedConfig =.*\)$/\1/g' ${PHPVBOX_INSTALL_DIR}/config.php
echo ">>>> Restarting vboxweb services <<<<"
systemctl --no-pager status vboxweb-service.service
systemctl --no-pager restart vboxweb-service.service
systemctl --no-pager status vboxweb-service.service
netstat -tulpena | grep 18083 || true
cat << EOT
******************************************************
* PHPVirtualBox is now installed. To access, go to: *
* http://localhost/phpvirtualbox *
* Username: admin *
* Password: admin *
* For security, by default, all connections are *
* blocked other than localhost. *
* To enable external connections* edit *
* /etc/apache2/conf-available/phpvirtualbox.conf *
* We recommend SSL + IP Blocking + Auth at a minimum *
******************************************************
EOT
fi
|