vboxvfs.sh revision 79f4c478fc236a59e3638bc01e3df7ae285bd1a9
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#! /bin/sh
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Sun xVM VirtualBox
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Linux Additions VFS kernel module init script
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
00550544656e1a1537bad42c4f4bacef814637cavboxsync#
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# available from http://www.virtualbox.org. This file is free software;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# you can redistribute it and/or modify it under the terms of the GNU
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# General Public License (GPL) as published by the Free Software
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# additional information or have any questions.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# chkconfig: 35 30 60
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# description: VirtualBox Linux Additions VFS kernel module
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync### BEGIN INIT INFO
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Provides: vboxvfs
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Required-Start: vboxadd
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Required-Stop:
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Default-Start: 3 5
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Default-Stop:
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync# Description: VirtualBox Linux Additions VFS kernel module
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync### END INIT INFO
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncPATH=$PATH:/bin:/sbin:/usr/sbin
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncif [ -f /etc/redhat-release ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync system=redhat
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncelif [ -f /etc/SuSE-release ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync system=suse
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncelif [ -f /etc/gentoo-release ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync system=gentoo
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncelse
101e4426c962b6d124219de44d4fd2cf2a23b178vboxsync system=other
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncif [ "$system" = "redhat" ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync . /etc/init.d/functions
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo_failure
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync succ_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo_success
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo -n "$1"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncif [ "$system" = "suse" ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync . /etc/rc.status
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync rc_failed 1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync rc_status -v
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync succ_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync rc_reset
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync rc_status -v
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo -n "$1"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsyncif [ "$system" = "gentoo" ]; then
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync . /sbin/functions.sh
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync fail_msg() {
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync eend 1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync succ_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync eend $?
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync ebegin $1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync if [ "`which $0`" = "/sbin/rc" ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync shift
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncif [ "$system" = "other" ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail_msg() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo " ...fail!"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync succ_msg() {
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync echo " ...done."
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo -n $1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynckdir=/lib/modules/`uname -r`/misc
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncmodname=vboxvfs
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncmodule="$kdir/$modname"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsyncfile=""
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsynctest -f $module.o && file=$module.o
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctest -f $module.ko && file=$module.ko
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncfail() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync if [ "$system" = "gentoo" ]; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync eerror $1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync exit 1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail_msg
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "($1)"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync exit 1
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync}
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctest -z "$file" && {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail "Kernel module not found"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync}
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncrunning() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync lsmod | grep -q $modname[^_-]
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync}
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncstart() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin "Starting VirtualBox Additions shared folder support ";
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync running || {
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync modprobe $modname > /dev/null 2>&1 || {
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync if dmesg | grep "vboxConnect failed" > /dev/null 2>&1; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail_msg
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "You may be trying to run Guest Additions from binary release of VirtualBox"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "in the Open Source Edition."
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync exit 1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fail "modprobe $modname failed"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync }
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync succ_msg
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync return 0
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync}
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncstop() {
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync begin "Stopping VirtualBox Additions shared folder support ";
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync if running; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync rmmod $modname || fail "Cannot unload module $modname"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync succ_msg
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync return 0
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync}
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncrestart() {
6bea637fe631bf8f14128c36c5da0fe98c0fa4edvboxsync stop && start
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync return 0
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync}
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsyncdmnstatus() {
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync if running; then
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "VirtualBox Additions shared folder support is currently running."
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync else
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "VirtualBox Additions shared folder support is not currently running."
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync fi
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync}
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynccase "$1" in
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncstart)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync start
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync ;;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncstop)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync stop
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync ;;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncrestart)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync restart
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync ;;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncstatus)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync dmnstatus
968c867cc19737e4e1fd97c396fcf75a3d52dd27vboxsync ;;
b84a3f2aac9529d5c5840512b12d81bc62d0e665vboxsync*)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync echo "Usage: $0 {start|stop|restart|status}"
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync exit 1
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncesac
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncexit
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync