VirtualBox

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

Last change on this file since 35650 was 33656, checked in by vboxsync, 14 years ago

*: rebrand Sun (L)GPL disclaimers

  • 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=$MODDIR32/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 -f "/etc/name_to_major"; then
60 loadentry=`cat /etc/name_to_major | grep "$1 "`
61 else
62 loadentry=`/usr/sbin/modinfo | grep "$1 "`
63 fi
64 if test -z "$loadentry"; then
65 return 1
66 fi
67 return 0
68}
69
70vboxguest_loaded()
71{
72 module_loaded $MODNAME
73 return $?
74}
75
76vboxfs_loaded()
77{
78 module_loaded $VFSMODNAME
79 return $?
80}
81
82check_root()
83{
84 # the reason we don't use "-u" is that some versions of id are old and do not
85 # support this option (eg. Solaris 10) and do not have a "--version" to check it either
86 # so go with the uglier but more generic approach
87 idbin=`which id`
88 isroot=`$idbin | grep "uid=0"`
89 if test -z "$isroot"; then
90 abort "This program must be run with administrator privileges. Aborting"
91 fi
92}
93
94start_module()
95{
96 if vboxguest_loaded; then
97 info "VirtualBox guest kernel module already loaded."
98 else
99 /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' $MODNAME
100 sync
101 if test ! vboxguest_loaded; then
102 abort "Failed to load VirtualBox guest kernel module."
103 elif test -c "/devices/pci@0,0/pci80ee,cafe@4:$MODNAME"; then
104 info "VirtualBox guest kernel module loaded."
105 else
106 abort "Aborting due to attach failure."
107 fi
108 fi
109}
110
111stop_module()
112{
113 if vboxguest_loaded; then
114 /usr/sbin/rem_drv $MODNAME || abort "## Failed to unload VirtualBox guest kernel module."
115 info "VirtualBox guest kernel module unloaded."
116 elif test -z "$SILENTUNLOAD"; then
117 info "VirtualBox guest kernel module not loaded."
118 fi
119}
120
121start_vboxfs()
122{
123 if vboxfs_loaded; then
124 info "VirtualBox FileSystem kernel module already loaded."
125 else
126 /usr/sbin/modload -p fs/$VFSMODNAME || abort "Failed to load VirtualBox FileSystem kernel module."
127 if test ! vboxfs_loaded; then
128 abort "Failed to load VirtualBox FileSystem kernel module."
129 else
130 info "VirtualBox FileSystem kernel module loaded."
131 fi
132 fi
133}
134
135stop_vboxfs()
136{
137 if vboxfs_loaded; then
138 vboxfs_mod_id=`/usr/sbin/modinfo | grep $VFSMODNAME | cut -f 1 -d ' ' `
139 if test -n "$vboxfs_mod_id"; then
140 /usr/sbin/modunload -i $vboxfs_mod_id || abort "Failed to unload VirtualBox FileSystem module."
141 info "VirtualBox FileSystem kernel module unloaded."
142 fi
143 elif test -z "$SILENTUNLOAD"; then
144 info "VirtualBox FileSystem kernel module not loaded."
145 fi
146}
147
148restart_module()
149{
150 stop_module
151 sync
152 start_module
153 return 0
154}
155
156restart_all()
157{
158 stop_module
159 sync
160 start_module
161 return 0
162}
163
164status_module()
165{
166 if vboxguest_loaded; then
167 info "Running."
168 else
169 info "Stopped."
170 fi
171}
172
173stop_all()
174{
175 stop_vboxfs
176 stop_module
177 return 0
178}
179
180check_root
181check_if_installed
182
183if test "$2" = "silentunload"; then
184 SILENTUNLOAD="$2"
185fi
186
187case "$1" in
188stopall)
189 stop_all
190 ;;
191restartall)
192 restart_all
193 ;;
194start)
195 start_module
196 ;;
197stop)
198 stop_module
199 ;;
200restart)
201 restart_module
202 ;;
203status)
204 status_module
205 ;;
206vfsstart)
207 start_vboxfs
208 ;;
209vfsstop)
210 stop_vboxfs
211 ;;
212*)
213 echo "Usage: $0 {start|stop|restart|status}"
214 exit 1
215esac
216
217exit 0
218
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