VirtualBox

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

Last change on this file since 31808 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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