VirtualBox

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

Last change on this file since 101359 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

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