VirtualBox

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

最後變更 在這個檔案從2988是 2988,由 vboxsync 提交於 18 年 前

InnoTek -> innotek part 4: more miscellaneous files.

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.4 KB
 
1#! /bin/sh
2# innotek VirtualBox
3# Linux Additions kernel module init script
4#
5# Copyright (C) 2006-2007 innotek 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:
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
25if [ -f /etc/redhat-release ]; then
26 system=redhat
27elif [ -f /etc/SuSE-release ]; then
28 system=suse
29elif [ -f /etc/gentoo-release ]; then
30 system=gentoo
31else
32 system=other
33fi
34
35if [ "$system" = "redhat" ]; then
36 . /etc/init.d/functions
37 fail_msg() {
38 echo_failure
39 echo
40 }
41
42 succ_msg() {
43 echo_success
44 echo
45 }
46
47 begin() {
48 echo -n "$1"
49 }
50fi
51
52if [ "$system" = "suse" ]; then
53 . /etc/rc.status
54 fail_msg() {
55 rc_failed 1
56 rc_status -v
57 }
58
59 succ_msg() {
60 rc_reset
61 rc_status -v
62 }
63
64 begin() {
65 echo -n "$1"
66 }
67fi
68
69if [ "$system" = "gentoo" ]; then
70 . /sbin/functions.sh
71 fail_msg() {
72 eend 1
73 }
74
75 succ_msg() {
76 eend $?
77 }
78
79 begin() {
80 ebegin $1
81 }
82
83 if [ "`which $0`" = "/sbin/rc" ]; then
84 shift
85 fi
86fi
87
88if [ "$system" = "other" ]; then
89 fail_msg() {
90 echo " ...fail!"
91 }
92
93 succ_msg() {
94 echo " ...done."
95 }
96
97 begin() {
98 echo -n $1
99 }
100fi
101
102kdir=/lib/modules/`uname -r`/misc
103dev=/dev/vboxadd
104modname=vboxadd
105module=$kdir/$modname
106
107file=""
108test -f $module.o && file=$module.o
109test -f $module.ko && file=$module.ko
110
111fail() {
112 if [ "$system" = "gentoo" ]; then
113 eerror $1
114 exit 1
115 fi
116 fail_msg
117 echo "($1)"
118 exit 1
119}
120
121test -z "$file" && {
122 fail "Kernel module not found"
123}
124
125running() {
126 lsmod | grep -q $modname[^_-]
127}
128
129start() {
130 begin "Starting VirtualBox Additions ";
131 running || {
132 rm -f $dev || {
133 fail "Cannot remove $dev"
134 }
135
136 modprobe $modname || {
137 fail "modprobe $modname failed"
138 }
139
140 sleep .5
141 }
142 if [ ! -c $dev ]; then
143 maj=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/devices`
144 if [ ! -z "$maj" ]; then
145 min=0
146 else
147 min=`sed -n 's;\([0-9]\+\) vboxadd;\1;p' /proc/misc`
148 if [ ! -z "$min" ]; then
149 maj=10
150 fi
151 fi
152 test -z "$maj" && {
153 rmmod $modname
154 fail "Cannot locate the VirtualBox device"
155 }
156
157 mknod -m 0664 $dev c $maj $min || {
158 rmmod $modname
159 fail "Cannot create device $dev with major $maj and minor $min"
160 }
161 fi
162
163 succ_msg
164 return 0
165}
166
167stop() {
168 begin "Stopping VirtualBox Additions ";
169 if running; then
170 rmmod $modname || fail "Cannot unload module $modname"
171 rm -f $dev || fail "Cannot unlink $dev"
172 fi
173 succ_msg
174 return 0
175}
176
177restart() {
178 stop && start
179 return 0
180}
181
182dmnstatus() {
183 if running; then
184 echo "The VirtualBox Additions are currently running."
185 else
186 echo "The VirtualBox Additions are not currently running."
187 fi
188}
189
190case "$1" in
191start)
192 start
193 ;;
194stop)
195 stop
196 ;;
197restart)
198 restart
199 ;;
200status)
201 dmnstatus
202 ;;
203*)
204 echo "Usage: $0 {start|stop|restart|status}"
205 exit 1
206esac
207
208exit
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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