summaryrefslogtreecommitdiffstats
path: root/core/modules/vbox/data/opt/openslx/scripts/systemd-vbox_env
blob: 64e138e4accdeea07d33bd8d1229a97cfe781c43 (plain) (blame)
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
#!/bin/ash
# -----------------------------------------------------------------------------
#
# Copyright (c) 2016..2018 bwLehrpool-Projektteam
#
# This program/file is free software distributed under the GPL version 2.
# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
#
# If you have any feedback please consult https://bwlehrpool.de and
# send your feedback to bwlehrpool@hs-offenburg.de.
#
# General information about bwLehrpool can be found at https://bwlehrpool.de
#
# -----------------------------------------------------------------------------
# systemd-vbox_env
#    - This is the preparation script for the configuration of VirtualBox.
################################################################################

export PATH="$PATH":/opt/openslx/bin:/opt/openslx/sbin
VBOX_CONF_DIR=/opt/openslx/etc/vbox
VBOXMANAGE=$(which vboxmanage)

# create required standard directories
mkdir -p "/tmp/virt/virtualbox" -m 1777

# load required Vbox modules
for module in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko vboxpci.ko ; do
  insmod /lib/modules/vbox/${module} || slxlog "vbox-systemd" "Loading of ${module} failed."
done

# unload modules if proper systemd shutdown is provided
#unload_modules () { 
#	rmmod vboxpci vboxnetflt vboxnetadp vboxdrv
#}

# Should be done by udev rule - no mknod needed.
# mknod -m 0660 /dev/vboxdrv c 10 59

chown root:vboxusers /dev/vboxdrv
chmod 666 /dev/vboxdrv
chown root:vboxusers /dev/vboxdrvu
chmod 666 /dev/vboxdrvu
chown root:vboxusers /dev/vboxusb
chmod 755 /dev/vboxusb

# pretty dumb you can just create host-only interfaces, but not assign a specific
# name/number
vboxmanage hostonlyif create
ip link set dev vboxnet0 up
brctl addif br0 vboxnet0
vboxmanage hostonlyif create 
ip link set dev vboxnet1 up
brctl addif nat1 vboxnet1
vboxmanage hostonlyif create
ip link set dev vboxnet2 up
brctl addif vsw2 vboxnet2