summaryrefslogblamecommitdiffstats
path: root/resources/config/1/uniontmp/etc/rc2.d/S20vbox-slx
blob: 093a79caf5d43d5813fad3df16f56d8bfdcada19 (plain) (tree)
























































































                                                                                            
#!/bin/sh
# Copyright (c) 2009 - 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/ 
# -----------------------------------------------------------------------------
# §filename§ 
#    - §desc§ 
# §generated§ 
# -----------------------------------------------------------------------------

### BEGIN INIT INFO
# Provides:             vbox-slx
# Required-Start:       $remote_fs
# Required-Stop:        $remote_fs
# Default-Start:        2 3 4 5
# Default-Stop:         1
# Short-Description:    Setup environment for virtualbox. Part of OpenSLX virtualbox plugin.
### END INIT INFO

. /lib/lsb/init-functions

#functions: helper functions
running () { 
lsmod | grep -q "$1[^_-]"
}

vmstatus () { 
if running vboxdrv; then
  if running vboxnetflt; then
    echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded."
  else
    echo "VirtualBox kernel module is loaded."
  fi
  #TODO: check it: ignore user check. handling our own way:
  for i in /tmp/.vbox-*-ipc; do
    echo "Running: "
      $(VBoxManage -q list runningvms | sed -e 's/^".*"//' 2>/dev/null)
    done
  else
    echo "VirtualBox kernel module(s) are not loaded."
fi

}

start () {
  echo "SUBSYSTEM==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0666\"" \
        >/etc/udev/rules.d/90-vboxusb.rules
  echo "SUBSYSTEM==\"usb\", ENV{DEVTYPE}==\"usb_device\",\
        GROUP=\"vboxusers\", MODE=\"0666\"" >>/etc/udev/rules.d/90-vboxusb.rules
  modprobe -qa vboxdrv vboxnetflt vboxnetadp
}

stop () { 
  rmmod vboxnetadp vboxnetflt vboxdrv
}


case "$1" in 
  start)
    #start: defines start function for initscript
    start
  ;;
  stop)
    #stop: defines stop function for initscript
    stop
  ;;
  restart)
    #restart: defines restart function for initscript
    stop && start
  ;;
  status)
    #status: defines status function for initscript
    vmstatus
  ;;
  *)
    #usage: defines usage function for initscript
    ## print out usage 
    echo "Usage: $0 {start, stop, restart, status}" >&2 
    exit 1
  ;;
esac

exit 0