summaryrefslogblamecommitdiffstats
path: root/core/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env
blob: 6e669a8a7cebd775e9413b4a8f89e9cfaedd70d5 (plain) (tree)





















                                                                                
                                         
 
                               
                                                
                                                                                    



                                                                        
                          

                     



                                                               

    


                                               
                       



                                  
 


                                       


                                                                                    

                                                       
                                


                           
                                


                           
                                

                           
 
      
#!/bin/ash
# -----------------------------------------------------------------------------
# Copyright (c) 2007..2013 - RZ Uni FR
# Copyright (c) 2007..2013 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# systemd-vbox_env
#    - This is the preparation script for the configuration of VirtualBox.
################################################################################

export PATH="$PATH":/opt/openslx/bin:/opt/openslx/sbin

## sanity checks
VBOX_BASE_DIR="/usr/lib/virtualbox"
VBOX_KMOD_DIR="/lib/modules/vbox"
VBOX_MANAGE="${VBOX_BASE_DIR}/VBoxManage"

# Runtime critical checks first
# VBoxManage should be under /usr/lib/virtualbox
if ! [ -d "${VBOX_BASE_DIR}" -o -x "${VBOX_MANAGE}" -o -d "${VBOX_KMOD_DIR}" ]; then
	echo "Failed to find VirtualBox installation at expected paths."
	exit 1
fi

# load vbox kernel modules
cd "${VBOX_KMOD_DIR}"
for MOD in *; do
	if ! insmod "${MOD}"; then
		slxlog "vbox-setup" "Loading of ${MOD} failed."
		exit 1
	fi
done

# check/create vboxusers group
getent group vboxusers || addgroup -S vboxusers

# set their permissions
chown root:vboxusers /dev/vboxdrv
chmod 666 /dev/vboxdrv
chown root:vboxusers /dev/vboxdrvu
chmod 666 /dev/vboxdrvu

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

# reload udev rules since aufs'ing the layer on top do not trigger its inotify watch
udevadm control --reload

# pretty dumb you can just create host-only interfaces,
# but not assign a specific name/number
${VBOX_MANAGE} hostonlyif create
ip link set dev vboxnet0 up
brctl addif br0 vboxnet0

${VBOX_MANAGE} hostonlyif create
ip link set dev vboxnet1 up
brctl addif nat1 vboxnet1

${VBOX_MANAGE} hostonlyif create
ip link set dev vboxnet2 up
brctl addif vsw2 vboxnet2

exit 0