| 1 | #! /bin/sh
|
|---|
| 2 | # innotek VirtualBox
|
|---|
| 3 | # Linux Additions VFS kernel module init script
|
|---|
| 4 | #
|
|---|
| 5 | # Copyright (C) 2006-2007 innotek GmbH
|
|---|
| 6 | #
|
|---|
| 7 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
|---|
| 8 | # available from http://www.virtualbox.org. This file is free software;
|
|---|
| 9 | # you can redistribute it and/or modify it under the terms of the GNU
|
|---|
| 10 | # General Public License as published by the Free Software Foundation,
|
|---|
| 11 | # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
|---|
| 12 | # distribution. VirtualBox OSE is distributed in the hope that it will
|
|---|
| 13 | # be useful, but WITHOUT ANY WARRANTY of any kind.
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | # chkconfig: 35 30 60
|
|---|
| 17 | # description: VirtualBox Linux Additions VFS kernel module
|
|---|
| 18 | #
|
|---|
| 19 | ### BEGIN INIT INFO
|
|---|
| 20 | # Provides: vboxvfs
|
|---|
| 21 | # Required-Start: vboxadd
|
|---|
| 22 | # Required-Stop:
|
|---|
| 23 | # Default-Start: 3 5
|
|---|
| 24 | # Default-Stop:
|
|---|
| 25 | # Description: VirtualBox Linux Additions VFS kernel module
|
|---|
| 26 | ### END INIT INFO
|
|---|
| 27 |
|
|---|
| 28 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
|---|
| 29 |
|
|---|
| 30 | if [ -f /etc/lfs-release ]; then
|
|---|
| 31 | system=lfs
|
|---|
| 32 | elif [ -f /etc/redhat-release ]; then
|
|---|
| 33 | system=redhat
|
|---|
| 34 | elif [ -f /etc/SuSE-release ]; then
|
|---|
| 35 | system=suse
|
|---|
| 36 | elif [ -f /etc/gentoo-release ]; then
|
|---|
| 37 | system=gentoo
|
|---|
| 38 | else
|
|---|
| 39 | system=other
|
|---|
| 40 | fi
|
|---|
| 41 |
|
|---|
| 42 | if [ "$system" = "lfs" ]; then
|
|---|
| 43 | . /etc/rc.d/init.d/functions
|
|---|
| 44 | fail_msg() {
|
|---|
| 45 | boot_mesg ""
|
|---|
| 46 | echo_failure
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | succ_msg() {
|
|---|
| 50 | boot_mesg ""
|
|---|
| 51 | echo_ok
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | begin() {
|
|---|
| 55 | echo -n "$1"
|
|---|
| 56 | }
|
|---|
| 57 | fi
|
|---|
| 58 |
|
|---|
| 59 | if [ "$system" = "redhat" ]; then
|
|---|
| 60 | . /etc/init.d/functions
|
|---|
| 61 | fail_msg() {
|
|---|
| 62 | echo_failure
|
|---|
| 63 | echo
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | succ_msg() {
|
|---|
| 67 | echo_success
|
|---|
| 68 | echo
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | begin() {
|
|---|
| 72 | echo -n "$1"
|
|---|
| 73 | }
|
|---|
| 74 | fi
|
|---|
| 75 |
|
|---|
| 76 | if [ "$system" = "suse" ]; then
|
|---|
| 77 | . /etc/rc.status
|
|---|
| 78 | fail_msg() {
|
|---|
| 79 | rc_failed 1
|
|---|
| 80 | rc_status -v
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | succ_msg() {
|
|---|
| 84 | rc_reset
|
|---|
| 85 | rc_status -v
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | begin() {
|
|---|
| 89 | echo -n "$1"
|
|---|
| 90 | }
|
|---|
| 91 | fi
|
|---|
| 92 |
|
|---|
| 93 | if [ "$system" = "gentoo" ]; then
|
|---|
| 94 | . /sbin/functions.sh
|
|---|
| 95 | fail_msg() {
|
|---|
| 96 | eend 1
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | succ_msg() {
|
|---|
| 100 | eend $?
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | begin() {
|
|---|
| 104 | ebegin $1
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | if [ "`which $0`" = "/sbin/rc" ]; then
|
|---|
| 108 | shift
|
|---|
| 109 | fi
|
|---|
| 110 | fi
|
|---|
| 111 |
|
|---|
| 112 | if [ "$system" = "other" ]; then
|
|---|
| 113 | fail_msg() {
|
|---|
| 114 | echo " ...fail!"
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | succ_msg() {
|
|---|
| 118 | echo " ...done."
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | begin() {
|
|---|
| 122 | echo -n $1
|
|---|
| 123 | }
|
|---|
| 124 | fi
|
|---|
| 125 |
|
|---|
| 126 | kdir=/lib/modules/`uname -r`/misc
|
|---|
| 127 | modname=vboxvfs
|
|---|
| 128 | module="$kdir/$modname"
|
|---|
| 129 |
|
|---|
| 130 | file=""
|
|---|
| 131 | test -f $module.o && file=$module.o
|
|---|
| 132 | test -f $module.ko && file=$module.ko
|
|---|
| 133 |
|
|---|
| 134 | fail() {
|
|---|
| 135 | if [ "$system" = "gentoo" ]; then
|
|---|
| 136 | eerror $1
|
|---|
| 137 | exit 1
|
|---|
| 138 | fi
|
|---|
| 139 | fail_msg
|
|---|
| 140 | echo "($1)"
|
|---|
| 141 | exit 1
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | test -z "$file" && {
|
|---|
| 145 | fail "Kernel module not found"
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | running() {
|
|---|
| 149 | lsmod | grep -q $modname[^_-]
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | start() {
|
|---|
| 153 | begin "Starting VirtualBox Additions shared folder support ";
|
|---|
| 154 | running || {
|
|---|
| 155 | modprobe $modname > /dev/null 2>&1 || {
|
|---|
| 156 | if dmesg | grep "vboxConnect failed" > /dev/null 2>&1; then
|
|---|
| 157 | fail_msg
|
|---|
| 158 | echo "You may be trying to run Guest Additions from binary release of VirtualBox"
|
|---|
| 159 | echo "in the Open Source Edition."
|
|---|
| 160 | exit 1
|
|---|
| 161 | fi
|
|---|
| 162 | fail "modprobe $modname failed"
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 | succ_msg
|
|---|
| 166 | return 0
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | stop() {
|
|---|
| 170 | begin "Stopping VirtualBox Additions shared folder support ";
|
|---|
| 171 | if running; then
|
|---|
| 172 | rmmod $modname || fail "Cannot unload module $modname"
|
|---|
| 173 | fi
|
|---|
| 174 | succ_msg
|
|---|
| 175 | return 0
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | restart() {
|
|---|
| 179 | stop && start
|
|---|
| 180 | return 0
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | dmnstatus() {
|
|---|
| 184 | if running; then
|
|---|
| 185 | echo "VirtualBox Additions shared folder support is currently running."
|
|---|
| 186 | else
|
|---|
| 187 | echo "VirtualBox Additions shared folder support is not currently running."
|
|---|
| 188 | fi
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | case "$1" in
|
|---|
| 192 | start)
|
|---|
| 193 | start
|
|---|
| 194 | ;;
|
|---|
| 195 | stop)
|
|---|
| 196 | stop
|
|---|
| 197 | ;;
|
|---|
| 198 | restart)
|
|---|
| 199 | restart
|
|---|
| 200 | ;;
|
|---|
| 201 | status)
|
|---|
| 202 | dmnstatus
|
|---|
| 203 | ;;
|
|---|
| 204 | *)
|
|---|
| 205 | echo "Usage: $0 {start|stop|restart|status}"
|
|---|
| 206 | exit 1
|
|---|
| 207 | esac
|
|---|
| 208 |
|
|---|
| 209 | exit
|
|---|