#! /bin/sh # # VirtualBox client init script for Slackware. PIDFILE="/var/run/vboxadd-service" # Check architecture cpu=`uname -m`; case "$cpu" in i[3456789]86|x86) cpu="x86" lib_path="/usr/lib" ;; x86_64|amd64) cpu="amd64" if test -d "/usr/lib64"; then lib_path="/usr/lib64" else lib_path="/usr/lib" fi ;; esac dev=/dev/vboxguest userdev=/dev/vboxuser owner=vboxguest group=vboxguest binary=/usr/sbin/VBoxService testbinary() { test -x "$binary" || { echo "Cannot run $binary" exit 1 } } vboxaddrunning() { lsmod | grep -q "vboxguest[^_-]" } running_vboxguest() { lsmod | grep -q "vboxguest[^_-]" } running_vboxadd() { lsmod | grep -q "vboxadd[^_-]" } running_vboxsf() { lsmod | grep -q "vboxsf[^_-]" } start() { # Make sure we have a home directory for the vboxguest account mkdir -p /var/run/vboxguest chown vboxguest:vboxguest /var/run/vboxguest # Daemon loading if ! test -f $PIDFILE; then echo -n "Starting VirtualBox Guest Addition service "; vboxaddrunning || { echo "VirtualBox Additions module not loaded!" exit 1 } testbinary $binary > /dev/null RETVAL=$? test $RETVAL -eq 0 && echo `pidof VBoxService` > $PIDFILE echo " done" fi return $RETVAL } stop() { RETVAL=0 if test -f $PIDFILE; then echo -n "Stopping VirtualBox Guest Addition service "; vboxaddrunning || { echo "VirtualBox Additions module not loaded!" exit 1 } kill $( cat $PIDFILE ) RETVAL=$? test $RETVAL -eq 0 && rm -f $PIDFILE echo " done" fi return $RETVAL } restart() { stop start return 0 } dmnstatus() { echo -n "Checking for VBoxService" if [ -f $PIDFILE ]; then echo " ...running" else echo " ...not running" fi } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) dmnstatus ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac exit