VirtualBox

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

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

Additions/solaris: Fix VBoxService loading using manifest class actions. Classify VBoxService under "applications" rather than "system".

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.8 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 if vboxguest_loaded; then
99 info "VirtualBox guest kernel module already loaded."
100 else
101 /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' $MODNAME
102 sync
103 if test ! vboxguest_loaded; then
104 abort "Failed to load VirtualBox guest kernel module."
105 elif test -c "/devices/pci@0,0/pci80ee,cafe@4:$MODNAME"; then
106 info "VirtualBox guest kernel module loaded."
107 else
108 abort "Aborting due to attach failure."
109 fi
110 fi
111}
112
113stop_module()
114{
115 if vboxguest_loaded; then
116 /usr/sbin/rem_drv $MODNAME || abort "Failed to unload VirtualBox guest kernel module."
117 info "VirtualBox guest kernel module unloaded."
118 elif test -z "$SILENTUNLOAD"; then
119 info "VirtualBox guest kernel module not loaded."
120 fi
121}
122
123start_vboxfs()
124{
125 if vboxfs_loaded; then
126 info "VirtualBox FileSystem kernel module already loaded."
127 else
128 /usr/sbin/modload -p fs/$VFSMODNAME || abort "Failed to load VirtualBox FileSystem kernel module."
129 if test ! vboxfs_loaded; then
130 abort "Failed to load VirtualBox FileSystem kernel module."
131 else
132 info "VirtualBox FileSystem kernel module loaded."
133 fi
134 fi
135}
136
137stop_vboxfs()
138{
139 if vboxfs_loaded; then
140 vboxfs_mod_id=`/usr/sbin/modinfo | grep $VFSMODNAME | cut -f 1 -d ' ' `
141 if test -n "$vboxfs_mod_id"; then
142 /usr/sbin/modunload -i $vboxfs_mod_id || abort "Failed to unload VirtualBox FileSystem module."
143 info "VirtualBox FileSystem kernel module unloaded."
144 fi
145 elif test -z "$SILENTUNLOAD"; then
146 info "VirtualBox FileSystem kernel module not loaded."
147 fi
148}
149
150status_module()
151{
152 if vboxguest_loaded; then
153 info "Running."
154 else
155 info "Stopped."
156 fi
157}
158
159stop_all()
160{
161 stop_vboxfs
162 stop_module
163 return 0
164}
165
166restart_all()
167{
168 stop_all
169 start_module
170 start_vboxfs
171 return 0
172}
173
174check_root
175check_if_installed
176
177if test "$2" = "silentunload"; then
178 SILENTUNLOAD="$2"
179fi
180
181case "$1" in
182stopall)
183 stop_all
184 ;;
185restartall)
186 restart_all
187 ;;
188start)
189 start_module
190 ;;
191stop)
192 stop_module
193 ;;
194status)
195 status_module
196 ;;
197vfsstart)
198 start_vboxfs
199 ;;
200vfsstop)
201 stop_vboxfs
202 ;;
203*)
204 echo "Usage: $0 {start|stop|restart|status}"
205 exit 1
206esac
207
208exit 0
209
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