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