VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/vboxadd.sh@ 1071

Last change on this file since 1071 was 495, checked in by vboxsync, 18 years ago

Additions installers are not OSE

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1#! /bin/sh
2# InnoTek VirtualBox
3# Linux Additions kernel module init script
4#
5# Copyright (C) 2006 InnoTek Systemberatung GmbH
6#
7# Use only with permission.
8#
9
10
11# chkconfig: 35 30 60
12# description: VirtualBox Linux Additions kernel module
13#
14### BEGIN INIT INFO
15# Provides: vboxadd
16# Required-Start: $syslog
17# Required-Stop:
18# Default-Start: 3 5
19# Default-Stop:
20# Description: VirtualBox Linux Additions kernel module
21### END INIT INFO
22
23PATH=$PATH:/bin:/sbin:/usr/sbin
24
25system=unknown
26if [ -f /etc/redhat-release ]; then
27 system=redhat
28elif [ -f /etc/SuSE-release ]; then
29 system=suse
30elif [ -f /etc/debian_version ]; then
31 system=debian
32elif [ -f /etc/gentoo-release ]; then
33 system=gentoo
34elif [ -f /etc/slackware-version ]; then
35 system=slackware
36else
37 echo "$0: Unknown system" 1>&2
38fi
39
40if [ "$system" = "redhat" ]; then
41 . /etc/init.d/functions
42 fail_msg() {
43 echo_failure
44 echo
45 }
46
47 succ_msg() {
48 echo_success
49 echo
50 }
51
52 begin() {
53 echo -n $1
54 }
55fi
56
57if [ "$system" = "suse" ]; then
58 . /etc/rc.status
59 fail_msg() {
60 rc_failed 1
61 rc_status -v
62 }
63
64 succ_msg() {
65 rc_reset
66 rc_status -v
67 }
68
69 begin() {
70 echo -n $1
71 }
72fi
73
74if [ "$system" = "debian" ]; then
75 fail_msg() {
76 echo " ...fail!"
77 }
78
79 succ_msg() {
80 echo " ...done."
81 }
82
83 begin() {
84 echo -n $1
85 }
86fi
87
88if [ "$system" = "gentoo" ]; then
89 . /sbin/functions.sh
90 fail_msg() {
91 eend 1
92 }
93
94 succ_msg() {
95 eend $?
96 }
97
98 begin() {
99 ebegin $1
100 }
101
102 if [ "`which $0`" = "/sbin/rc" ]; then
103 shift
104 fi
105fi
106
107if [ "$system" = "slackware" ]; then
108 fail_msg() {
109 echo " ...fail!"
110 }
111
112 succ_msg() {
113 echo " ...done."
114 }
115
116 begin() {
117 echo -n $1
118 }
119fi
120
121kdir=/lib/modules/`uname -r`/misc
122dev=/dev/vboxadd
123modname=vboxadd
124module=$kdir/$modname
125
126file=""
127test -f $module.o && file=$module.o
128test -f $module.ko && file=$module.ko
129
130fail() {
131 if [ "$system" = "gentoo" ]; then
132 eerror $1
133 exit 1
134 fi
135 fail_msg
136 echo "($1)"
137 exit 1
138}
139
140test -z "$file" && {
141 fail "Kernel module not found"
142}
143
144running() {
145 lsmod | grep -q $modname[^_-]
146}
147
148start() {
149 begin "Starting VirtualBox Additions ";
150 running || {
151 rm -f $dev || {
152 fail "Cannot remove $dev"
153 }
154
155 modprobe $modname || {
156 fail "modprobe $modname failed"
157 }
158
159 sleep 1
160 }
161 if [ ! -c $dev ]; then
162 maj=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/devices`
163 if [ ! -z "$maj" ]; then
164 min=0
165 else
166 min=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/misc`
167 if [ ! -z "$min" ]; then
168 maj=10
169 fi
170 fi
171 test -z "$maj" && {
172 rmmod $modname
173 fail "Cannot locate the VirtualBox device"
174 }
175
176 mknod -m 0664 $dev c $maj $min || {
177 rmmod $modname
178 fail "Cannot create device $dev with major $maj and minor $min"
179 }
180 fi
181
182 succ_msg
183 return 0
184}
185
186stop() {
187 begin "Stopping VirtualBox Additions ";
188 if running; then
189 rmmod $modname || fail "Cannot unload module $modname"
190 rm -f $dev || fail "Cannot unlink $dev"
191 fi
192 succ_msg
193 return 0
194}
195
196restart() {
197 stop && start
198 return 0
199}
200
201dmnstatus() {
202 if running; then
203 echo "The VirtualBox Additions are currently running."
204 else
205 echo "The VirtualBox Additions are not currently running."
206 fi
207}
208
209case "$1" in
210start)
211 start
212 ;;
213stop)
214 stop
215 ;;
216restart)
217 restart
218 ;;
219status)
220 dmnstatus
221 ;;
222*)
223 echo "Usage: $0 {start|stop|restart|status}"
224 exit 1
225esac
226
227exit
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette