VirtualBox

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

Last change on this file since 17311 was 17031, checked in by vboxsync, 16 years ago

Solaris/Additions: SharedFolders and pkgchk consistency.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1#!/bin/sh
2# Sun xVM VirtualBox
3# VirtualBox Guest Additions kernel module control script for Solaris.
4#
5# Copyright (C) 2008 Sun Microsystems, Inc.
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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
16# Clara, CA 95054 USA or visit http://www.sun.com if you need
17# additional information or have any questions.
18#
19
20SILENTUNLOAD=""
21MODNAME="vboxguest"
22VFSMODNAME="vboxvfs"
23MODDIR32="/usr/kernel/drv"
24MODDIR64=$MODDIR32/amd64
25VFSDIR32="/usr/kernel/fs"
26VFSDIR64="/usr/kernel/fs/amd64"
27
28abort()
29{
30 echo 1>&2 "## $1"
31 exit 1
32}
33
34info()
35{
36 echo 1>&2 "$1"
37}
38
39check_if_installed()
40{
41 cputype=`isainfo -k`
42 modulepath="$MODDIR32/$MODNAME"
43 if test "$cputype" = "amd64"; then
44 modulepath="$MODDIR64/$MODNAME"
45 fi
46 if test -f "$modulepath"; then
47 return 0
48 fi
49 abort "VirtualBox kernel module ($MODNAME) NOT installed."
50}
51
52module_loaded()
53{
54 if test -f "/etc/name_to_major"; then
55 loadentry=`cat /etc/name_to_major | grep $1`
56 else
57 loadentry=`/usr/sbin/modinfo | grep $1`
58 fi
59 if test -z "$loadentry"; then
60 return 1
61 fi
62 return 0
63}
64
65vboxguest_loaded()
66{
67 module_loaded $MODNAME
68 return $?
69}
70
71vboxvfs_loaded()
72{
73 module_loaded $VFSMODNAME
74 return $?
75}
76
77check_root()
78{
79 if test `/usr/xpg4/bin/id -u` -ne 0; then
80 abort "This program must be run with administrator privileges. Aborting"
81 fi
82}
83
84start_module()
85{
86 if vboxguest_loaded; then
87 info "VirtualBox guest kernel module already loaded."
88 else
89 /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' $MODNAME
90 if test ! vboxguest_loaded; then
91 abort "Failed to load VirtualBox guest kernel module."
92 elif test -c "/devices/pci@0,0/pci80ee,cafe@4:$MODNAME"; then
93 info "VirtualBox guest kernel module loaded."
94 else
95 stop
96 abort "Aborting due to attach failure."
97 fi
98 fi
99}
100
101stop_module()
102{
103 if vboxguest_loaded; then
104 /usr/sbin/rem_drv $MODNAME || abort "## Failed to unload VirtualBox guest kernel module."
105 info "VirtualBox guest kernel module unloaded."
106 elif test -z "$SILENTUNLOAD"; then
107 info "VirtualBox guest kernel module not loaded."
108 fi
109}
110
111start_vboxvfs()
112{
113 if vboxvfs_loaded; then
114 info "VirtualBox FileSystem kernel module already loaded."
115 else
116 /usr/sbin/modload -p fs/$VFSMODNAME || abort "Failed to load VirtualBox FileSystem kernel module."
117 if test ! vboxvfs_loaded; then
118 abort "Failed to load VirtualBox FileSystem kernel module."
119 else
120 info "VirtualBox FileSystem kernel module loaded."
121 fi
122 fi
123}
124
125stop_vboxvfs()
126{
127 if vboxvfs_loaded; then
128 vboxvfs_mod_id=`/usr/sbin/modinfo | grep $VFSMODNAME | cut -f 1 -d ' ' `
129 if test -n "$vboxvfs_mod_id"; then
130 /usr/sbin/modunload -i $vboxvfs_mod_id || abort "Failed to unload VirtualBox FileSystem module."
131 info "VirtualBox FileSystem kernel module unloaded."
132 fi
133 elif test -z "$SILENTUNLOAD"; then
134 info "VirtualBox FileSystem kernel module not loaded."
135 fi
136}
137
138restart_module()
139{
140 stop_module
141 sync
142 start_module
143 return 0
144}
145
146restart_all()
147{
148 stop_module
149 sync
150 start_module
151 return 0
152}
153
154status_module()
155{
156 if vboxguest_loaded; then
157 info "Running."
158 else
159 info "Stopped."
160 fi
161}
162
163stop_all()
164{
165 stop_vboxvfs
166 stop_module
167 return 0
168}
169
170check_root
171check_if_installed
172
173if test "$2" = "silentunload"; then
174 SILENTUNLOAD="$2"
175fi
176
177case "$1" in
178stopall)
179 stop_all
180 ;;
181restartall)
182 restart_all
183 ;;
184start)
185 start_module
186 ;;
187stop)
188 stop_module
189 ;;
190restart)
191 restart_module
192 ;;
193status)
194 status_module
195 ;;
196vfsstart)
197 start_vboxvfs
198 ;;
199vfsstop)
200 stop_vboxvfs
201 ;;
202*)
203 echo "Usage: $0 {start|stop|restart|status}"
204 exit 1
205esac
206
207exit 0
208
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