VirtualBox

source: vbox/trunk/src/VBox/Additions/solaris/Installer/vboxguest.sh@ 59001

Last change on this file since 59001 was 59001, checked in by vboxsync, 9 years ago

bugref:8153: vboxvideo: ABI issues / software rendering on Linux guests: change Solaris installers to install our 3D library at Additions start time rather than at install time, and to only do it if 3D pass-through is currently enabled.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1#!/bin/sh
2#
3# VirtualBox Guest Additions kernel module control script for Solaris.
4#
5# Copyright (C) 2008-2012 Oracle Corporation
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 (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# The contents of this file may alternatively be used under the terms
16# of the Common Development and Distribution License Version 1.0
17# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
18# VirtualBox OSE distribution, in which case the provisions of the
19# CDDL are applicable instead of those of the GPL.
20#
21# You may elect to license modified versions of this file under the
22# terms and conditions of either the GPL or the CDDL or both.
23#
24
25LC_ALL=C
26export LC_ALL
27
28LANG=C
29export LANG
30
31SILENTUNLOAD=""
32MODNAME="vboxguest"
33VFSMODNAME="vboxfs"
34VMSMODNAME="vboxms"
35MODDIR32="/usr/kernel/drv"
36MODDIR64="/usr/kernel/drv/amd64"
37VFSDIR32="/usr/kernel/fs"
38VFSDIR64="/usr/kernel/fs/amd64"
39
40abort()
41{
42 echo 1>&2 "## $1"
43 exit 1
44}
45
46info()
47{
48 echo 1>&2 "$1"
49}
50
51check_if_installed()
52{
53 cputype=`isainfo -k`
54 modulepath="$MODDIR32/$MODNAME"
55 if test "$cputype" = "amd64"; then
56 modulepath="$MODDIR64/$MODNAME"
57 fi
58 if test -f "$modulepath"; then
59 return 0
60 fi
61 abort "VirtualBox kernel module ($MODNAME) NOT installed."
62}
63
64module_loaded()
65{
66 if test -z "$1"; then
67 abort "missing argument to module_loaded()"
68 fi
69
70 modname=$1
71 # modinfo should now work properly since we prevent module autounloading.
72 loadentry=`/usr/sbin/modinfo | grep "$modname "`
73 if test -z "$loadentry"; then
74 return 1
75 fi
76 return 0
77}
78
79vboxguest_loaded()
80{
81 module_loaded $MODNAME
82 return $?
83}
84
85vboxfs_loaded()
86{
87 module_loaded $VFSMODNAME
88 return $?
89}
90
91vboxms_loaded()
92{
93 module_loaded $VMSMODNAME
94 return $?
95}
96
97check_root()
98{
99 # the reason we don't use "-u" is that some versions of id are old and do not
100 # support this option (eg. Solaris 10) and do not have a "--version" to check it either
101 # so go with the uglier but more generic approach
102 idbin=`which id`
103 isroot=`$idbin | grep "uid=0"`
104 if test -z "$isroot"; then
105 abort "This program must be run with administrator privileges. Aborting"
106 fi
107}
108
109start_module()
110{
111 /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' $MODNAME
112 if test ! vboxguest_loaded; then
113 abort "Failed to load VirtualBox guest kernel module."
114 elif test -c "/devices/pci@0,0/pci80ee,cafe@4:$MODNAME"; then
115 info "VirtualBox guest kernel module loaded."
116 else
117 info "VirtualBox guest kernel module failed to attach."
118 fi
119}
120
121stop_module()
122{
123 if vboxguest_loaded; then
124 /usr/sbin/rem_drv $MODNAME || abort "Failed to unload VirtualBox guest kernel module."
125 info "VirtualBox guest kernel module unloaded."
126 elif test -z "$SILENTUNLOAD"; then
127 info "VirtualBox guest kernel module not loaded."
128 fi
129}
130
131start_vboxfs()
132{
133 if vboxfs_loaded; then
134 info "VirtualBox FileSystem kernel module already loaded."
135 else
136 /usr/sbin/modload -p fs/$VFSMODNAME || abort "Failed to load VirtualBox FileSystem kernel module."
137 if test ! vboxfs_loaded; then
138 info "Failed to load VirtualBox FileSystem kernel module."
139 else
140 info "VirtualBox FileSystem kernel module loaded."
141 fi
142 fi
143}
144
145stop_vboxfs()
146{
147 if vboxfs_loaded; then
148 vboxfs_mod_id=`/usr/sbin/modinfo | grep $VFSMODNAME | cut -f 1 -d ' ' `
149 if test -n "$vboxfs_mod_id"; then
150 /usr/sbin/modunload -i $vboxfs_mod_id || abort "Failed to unload VirtualBox FileSystem module."
151 info "VirtualBox FileSystem kernel module unloaded."
152 fi
153 elif test -z "$SILENTUNLOAD"; then
154 info "VirtualBox FileSystem kernel module not loaded."
155 fi
156}
157
158start_vboxms()
159{
160 /usr/sbin/add_drv -m'* 0666 root sys' $VMSMODNAME
161 if test ! vboxms_loaded; then
162 abort "Failed to load VirtualBox pointer integration module."
163 elif test -c "/devices/pseudo/$VMSMODNAME@0:$VMSMODNAME"; then
164 info "VirtualBox pointer integration module loaded."
165 else
166 info "VirtualBox pointer integration module failed to attach."
167 fi
168}
169
170stop_vboxms()
171{
172 if vboxms_loaded; then
173 /usr/sbin/rem_drv $VMSMODNAME || abort "Failed to unload VirtualBox pointer integration module."
174 info "VirtualBox pointer integration module unloaded."
175 elif test -z "$SILENTUNLOAD"; then
176 info "VirtualBox pointer integration module not loaded."
177 fi
178}
179
180install_3d()
181{
182 # 32-bit crogl opengl library replacement
183 if test -f /system/volatile/opengl/lib/libGL.so.1 && test -f /usr/lib/VBoxOGL.so && \
184 /usr/bin/VBoxClient --check3d; then
185 rm -f /system/volatile/opengl/lib/libGL.so.1
186 ln -sf /usr/lib/VBoxOGL.so /system/volatile/opengl/lib/libGL.so.1
187 fi
188
189 # 64-bit crogl opengl library replacement
190 if test -f /system/volatile/opengl/lib/amd64/libGL.so.1 && test -f /usr/lib/amd64/VBoxOGL.so && \
191 /usr/bin/VBoxClient --check3d; then
192 rm -f /system/volatile/opengl/lib/amd64/libGL.so.1
193 ln -sf /usr/lib/amd64/VBoxOGL.so /system/volatile/opengl/lib/amd64/libGL.so.1
194 fi
195}
196
197remove_3d()
198{
199 # 32-bit crogl opengl library replacement
200 if test -f /system/volatile/opengl/lib/libGL.so.1 && test -f "/usr/lib/mesa/libGL.so.1"; then
201 rm -f /system/volatile/opengl/lib/libGL.so.1
202 ln -sf /usr/lib/mesa/libGL.so.1 /system/volatile/opengl/lib/libGL.so.1
203 elif test -f /system/volatile/opengl/lib/libGL.so.1 && test -f "/usr/X11/lib/mesa/libGL.so.1"; then
204 rm -f /system/volatile/opengl/lib/libGL.so.1
205 ln -sf /usr/X11/lib/mesa/libGL.so.1 /system/volatile/opengl/lib/libGL.so.1
206 fi
207
208 # 64-bit crogl opengl library replacement
209 if test -f /system/volatile/opengl/lib/amd64/libGL.so.1 && test -f "/usr/lib/mesa/amd64/libGL.so.1"; then
210 rm -f /system/volatile/opengl/lib/amd64/libGL.so.1
211 ln -sf /usr/lib/mesa/amd64/libGL.so.1 /system/volatile/opengl/lib/amd64/libGL.so.1
212 elif test -f /system/volatile/opengl/lib/amd64/libGL.so.1 && test -f "/usr/X11/lib/mesa/amd64/libGL.so.1"; then
213 rm -f /system/volatile/opengl/lib/amd64/libGL.so.1
214 ln -sf /usr/X11/lib/mesa/amd64/libGL.so.1 /system/volatile/opengl/lib/amd64/libGL.so.1
215 fi
216}
217
218status_module()
219{
220 if vboxguest_loaded; then
221 info "Running."
222 else
223 info "Stopped."
224 fi
225}
226
227stop_all()
228{
229 remove_3d
230 stop_vboxms
231 stop_vboxfs
232 stop_module
233 return 0
234}
235
236restart_all()
237{
238 stop_all
239 start_module
240 start_vboxfs
241 start_vboxms
242 install_3d
243 return 0
244}
245
246check_root
247check_if_installed
248
249if test "$2" = "silentunload"; then
250 SILENTUNLOAD="$2"
251fi
252
253case "$1" in
254stopall)
255 stop_all
256 ;;
257restartall)
258 restart_all
259 ;;
260start)
261 start_module
262 start_vboxms
263 install_3d
264 ;;
265stop)
266 remove_3d
267 stop_vboxms
268 stop_module
269 ;;
270status)
271 status_module
272 ;;
273vfsstart)
274 start_vboxfs
275 ;;
276vfsstop)
277 stop_vboxfs
278 ;;
279vmsstart)
280 start_vboxms
281 ;;
282vmsstop)
283 stop_vboxms
284 ;;
2853dstart)
286 install_3d
287 ;;
2883dstop)
289 remove_3d
290 ;;
291*)
292 echo "Usage: $0 {start|stop|restart|status}"
293 exit 1
294esac
295
296exit 0
297
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