VirtualBox

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

Last change on this file since 39761 was 39761, checked in by vboxsync, 13 years ago

Additions/solaris/Installer: fix 4.1.8 regression with driver loading (public #10113)

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1#!/bin/sh
2#
3# VirtualBox Guest Additions kernel module control script for Solaris.
4#
5# Copyright (C) 2008-2010 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
25SILENTUNLOAD=""
26MODNAME="vboxguest"
27VFSMODNAME="vboxfs"
28MODDIR32="/usr/kernel/drv"
29MODDIR64="/usr/kernel/drv/amd64"
30VFSDIR32="/usr/kernel/fs"
31VFSDIR64="/usr/kernel/fs/amd64"
32
33abort()
34{
35 echo 1>&2 "## $1"
36 exit 1
37}
38
39info()
40{
41 echo 1>&2 "$1"
42}
43
44check_if_installed()
45{
46 cputype=`isainfo -k`
47 modulepath="$MODDIR32/$MODNAME"
48 if test "$cputype" = "amd64"; then
49 modulepath="$MODDIR64/$MODNAME"
50 fi
51 if test -f "$modulepath"; then
52 return 0
53 fi
54 abort "VirtualBox kernel module ($MODNAME) NOT installed."
55}
56
57module_loaded()
58{
59 if test -z "$1"; then
60 abort "missing argument to module_loaded()"
61 fi
62
63 modname=$1
64 # modinfo should now work properly since we prevent module autounloading.
65 loadentry=`/usr/sbin/modinfo | grep "$modname "`
66 if test -z "$loadentry"; then
67 return 1
68 fi
69 return 0
70}
71
72vboxguest_loaded()
73{
74 module_loaded $MODNAME
75 return $?
76}
77
78vboxfs_loaded()
79{
80 module_loaded $VFSMODNAME
81 return $?
82}
83
84check_root()
85{
86 # the reason we don't use "-u" is that some versions of id are old and do not
87 # support this option (eg. Solaris 10) and do not have a "--version" to check it either
88 # so go with the uglier but more generic approach
89 idbin=`which id`
90 isroot=`$idbin | grep "uid=0"`
91 if test -z "$isroot"; then
92 abort "This program must be run with administrator privileges. Aborting"
93 fi
94}
95
96start_module()
97{
98 /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' $MODNAME
99 if test ! vboxguest_loaded; then
100 abort "Failed to load VirtualBox guest kernel module."
101 elif test -c "/devices/pci@0,0/pci80ee,cafe@4:$MODNAME"; then
102 info "VirtualBox guest kernel module loaded."
103 else
104 abort "Aborting due to attach failure."
105 fi
106}
107
108stop_module()
109{
110 if vboxguest_loaded; then
111 /usr/sbin/rem_drv $MODNAME || abort "Failed to unload VirtualBox guest kernel module."
112 info "VirtualBox guest kernel module unloaded."
113 elif test -z "$SILENTUNLOAD"; then
114 info "VirtualBox guest kernel module not loaded."
115 fi
116}
117
118start_vboxfs()
119{
120 if vboxfs_loaded; then
121 info "VirtualBox FileSystem kernel module already loaded."
122 else
123 /usr/sbin/modload -p fs/$VFSMODNAME || abort "Failed to load VirtualBox FileSystem kernel module."
124 if test ! vboxfs_loaded; then
125 abort "Failed to load VirtualBox FileSystem kernel module."
126 else
127 info "VirtualBox FileSystem kernel module loaded."
128 fi
129 fi
130}
131
132stop_vboxfs()
133{
134 if vboxfs_loaded; then
135 vboxfs_mod_id=`/usr/sbin/modinfo | grep $VFSMODNAME | cut -f 1 -d ' ' `
136 if test -n "$vboxfs_mod_id"; then
137 /usr/sbin/modunload -i $vboxfs_mod_id || abort "Failed to unload VirtualBox FileSystem module."
138 info "VirtualBox FileSystem kernel module unloaded."
139 fi
140 elif test -z "$SILENTUNLOAD"; then
141 info "VirtualBox FileSystem kernel module not loaded."
142 fi
143}
144
145status_module()
146{
147 if vboxguest_loaded; then
148 info "Running."
149 else
150 info "Stopped."
151 fi
152}
153
154stop_all()
155{
156 stop_vboxfs
157 stop_module
158 return 0
159}
160
161restart_all()
162{
163 stop_all
164 start_module
165 start_vboxfs
166 return 0
167}
168
169check_root
170check_if_installed
171
172if test "$2" = "silentunload"; then
173 SILENTUNLOAD="$2"
174fi
175
176case "$1" in
177stopall)
178 stop_all
179 ;;
180restartall)
181 restart_all
182 ;;
183start)
184 start_module
185 ;;
186stop)
187 stop_module
188 ;;
189status)
190 status_module
191 ;;
192vfsstart)
193 start_vboxfs
194 ;;
195vfsstop)
196 stop_vboxfs
197 ;;
198*)
199 echo "Usage: $0 {start|stop|restart|status}"
200 exit 1
201esac
202
203exit 0
204
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