VirtualBox

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

Last change on this file since 170 was 1, checked in by vboxsync, 55 years ago

import

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

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