VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/vboxdrv.sh@ 7692

Last change on this file since 7692 was 7692, checked in by vboxsync, 17 years ago

Solaris installer: export to OSE

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/bash
2# innotek VirtualBox
3# VirtualBox kernel module control script for Solaris.
4#
5# Copyright (C) 2007-2008 innotek GmbH
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
16VBOXDRVFILE=""
17SILENTUNLOAD=""
18
19abort()
20{
21 echo 1>&2 "$1"
22 exit 1
23}
24
25info()
26{
27 echo 1>&2 "$1"
28}
29
30get_module_path()
31{
32 cputype=`isainfo -k`
33 moduledir="/platform/i86pc/kernel/drv";
34 if test "$cputype" = "amd64"; then
35 moduledir=$moduledir/amd64
36 fi
37 modulepath=$moduledir/vboxdrv
38 if test -f "$modulepath"; then
39 VBOXDRVFILE="$modulepath"
40 else
41 VBOXDRVFILE=""
42 fi
43}
44
45check_if_installed()
46{
47 if test "$VBOXDRVFILE" -a -f "$VBOXDRVFILE"; then
48 return 0
49 fi
50 abort "VirtualBox kernel module (vboxdrv) not installed."
51}
52
53module_loaded()
54{
55 if test -f "/etc/name_to_major"; then
56 loadentry=`cat /etc/name_to_major | grep vboxdrv`
57 else
58 loadentry=`/usr/sbin/modinfo | grep vboxdrv`
59 fi
60 if test -z "$loadentry"; then
61 return 1
62 fi
63 return 0
64}
65
66check_root()
67{
68 if test `id -u` -ne 0; then
69 abort "This program must be run with administrator privileges. Aborting"
70 fi
71}
72
73start()
74{
75 if module_loaded; then
76 info "vboxdrv already loaded..."
77 else
78 /usr/sbin/add_drv -m'* 0666 root sys' vboxdrv
79 if ! module_loaded; then
80 abort "Failed to load vboxdrv."
81 elif test -c "/devices/pseudo/vboxdrv@0:vboxdrv"; then
82 info "Loaded vboxdrv."
83 else
84 stop
85 abort "Aborting due to attach failure."
86 fi
87 fi
88}
89
90stop()
91{
92 if module_loaded; then
93 /usr/sbin/rem_drv vboxdrv
94 info "Unloaded vboxdrv."
95 elif test -z "$SILENTUNLOAD"; then
96 info "vboxdrv not loaded."
97 fi
98}
99
100restart()
101{
102 stop
103 sync
104 start
105 return 0
106}
107
108status()
109{
110 if module_loaded; then
111 info "vboxdrv running."
112 else
113 info "vboxdrv stopped."
114 fi
115}
116
117check_root
118get_module_path
119check_if_installed
120
121if test "$2" = "silentunload"; then
122 SILENTUNLOAD="$2"
123fi
124
125case "$1" in
126start)
127 start
128 ;;
129stop)
130 stop
131 ;;
132restart)
133 restart
134 ;;
135status)
136 status
137 ;;
138*)
139 echo "Usage: $0 {start|stop|restart|status}"
140 exit 1
141esac
142
143exit
144
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