1 | #!/bin/sh
|
---|
2 | # $Id: checkinstall.sh 56564 2015-06-19 15:17:45Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | #
|
---|
5 | # VirtualBox checkinstall script for Solaris.
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2009-2015 Oracle Corporation
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | # available from http://www.virtualbox.org. This file is free software;
|
---|
13 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | # General Public License (GPL) as published by the Free Software
|
---|
15 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | #
|
---|
19 |
|
---|
20 | infoprint()
|
---|
21 | {
|
---|
22 | echo 1>&2 "$1"
|
---|
23 | }
|
---|
24 |
|
---|
25 | errorprint()
|
---|
26 | {
|
---|
27 | echo 1>&2 "## $1"
|
---|
28 | }
|
---|
29 |
|
---|
30 | abort_error()
|
---|
31 | {
|
---|
32 | errorprint "Please close all VirtualBox processes and re-run this installer."
|
---|
33 | exit 1
|
---|
34 | }
|
---|
35 |
|
---|
36 | checkdep_svr4()
|
---|
37 | {
|
---|
38 | if test -z "$1"; then
|
---|
39 | errorprint "Missing argument to checkdep_svr4"
|
---|
40 | return 1
|
---|
41 | fi
|
---|
42 | $BIN_PKGINFO $BASEDIR_OPT "$1" >/dev/null 2>&1
|
---|
43 | if test $? -eq 0; then
|
---|
44 | return 0
|
---|
45 | fi
|
---|
46 | PKG_MISSING_SVR4="$PKG_MISSING_SVR4 $1"
|
---|
47 | return 1
|
---|
48 | }
|
---|
49 |
|
---|
50 | checkdep_ips()
|
---|
51 | {
|
---|
52 | if test -z "$1"; then
|
---|
53 | errorprint "Missing argument to checkdep_ips"
|
---|
54 | return 1
|
---|
55 | fi
|
---|
56 | # using "list" without "-a" only lists installed pkgs which is what we need
|
---|
57 | $BIN_PKG $BASEDIR_OPT list "$1" >/dev/null 2>&1
|
---|
58 | if test $? -eq 0; then
|
---|
59 | return 0
|
---|
60 | fi
|
---|
61 | PKG_MISSING_IPS="$PKG_MISSING_IPS $1"
|
---|
62 | return 1
|
---|
63 | }
|
---|
64 |
|
---|
65 | checkdep_ips_either()
|
---|
66 | {
|
---|
67 | if test -z "$1" || test -z "$2"; then
|
---|
68 | errorprint "Missing argument to checkdep_ips_either"
|
---|
69 | return 1
|
---|
70 | fi
|
---|
71 | # using "list" without "-a" only lists installed pkgs which is what we need
|
---|
72 | $BIN_PKG $BASEDIR_OPT list "$1" >/dev/null 2>&1
|
---|
73 | if test $? -eq 0; then
|
---|
74 | return 0
|
---|
75 | fi
|
---|
76 | $BIN_PKG $BASEDIR_OPT list "$2" >/dev/null 2>&1
|
---|
77 | if test $? -eq 0; then
|
---|
78 | return 0
|
---|
79 | fi
|
---|
80 | PKG_MISSING_IPS="$PKG_MISSING_IPS $1 or $2"
|
---|
81 | return 1
|
---|
82 | }
|
---|
83 |
|
---|
84 | disable_service()
|
---|
85 | {
|
---|
86 | if test -z "$1" || test -z "$2"; then
|
---|
87 | errorprint "Missing argument to disable_service"
|
---|
88 | return 1
|
---|
89 | fi
|
---|
90 | servicefound=`$BIN_SVCS -H "$1" 2> /dev/null | grep '^online'`
|
---|
91 | if test ! -z "$servicefound"; then
|
---|
92 | infoprint "$2 ($1) is still enabled. Disabling..."
|
---|
93 | $BIN_SVCADM disable -s "$1"
|
---|
94 | # Don't delete the service, handled by manifest class action
|
---|
95 | # /usr/sbin/svccfg delete $1
|
---|
96 | fi
|
---|
97 | }
|
---|
98 |
|
---|
99 | #
|
---|
100 | # Begin execution
|
---|
101 | #
|
---|
102 |
|
---|
103 | # Nothing to check for remote install
|
---|
104 | REMOTE_INST=0
|
---|
105 | if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
|
---|
106 | BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
|
---|
107 | REMOTE_INST=1
|
---|
108 | fi
|
---|
109 |
|
---|
110 | # Nothing to check for non-global zones
|
---|
111 | currentzone=`zonename`
|
---|
112 | if test "$currentzone" != "global"; then
|
---|
113 | exit 0
|
---|
114 | fi
|
---|
115 |
|
---|
116 | PKG_MISSING_IPS=""
|
---|
117 | PKG_MISSING_SVR4=""
|
---|
118 | BIN_PKGINFO=`which pkginfo 2> /dev/null`
|
---|
119 | BIN_PKG=`which pkg 2> /dev/null`
|
---|
120 | BIN_SVCS=`which svcs 2> /dev/null`
|
---|
121 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
122 |
|
---|
123 | # Check if our binaries are fine
|
---|
124 | if test ! -x "$BIN_SVCS"; then
|
---|
125 | errorprint "Missing or non-executable binary: svcs ($BIN_SVCS)."
|
---|
126 | exit 1
|
---|
127 | fi
|
---|
128 | if test ! -x "$BIN_SVCADM"; then
|
---|
129 | errorprint "Missing or non-executable binary: svcadm ($BIN_SVCADM)."
|
---|
130 | exit 1
|
---|
131 | fi
|
---|
132 |
|
---|
133 | infoprint "Checking package dependencies..."
|
---|
134 |
|
---|
135 | if test -x "$BIN_PKG"; then
|
---|
136 | checkdep_ips "runtime/python-26"
|
---|
137 | checkdep_ips_either "system/library/iconv/utf-8" "system/library/iconv/iconv-core"
|
---|
138 | else
|
---|
139 | PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8"
|
---|
140 | fi
|
---|
141 | if test -x "$BIN_PKGINFO"; then
|
---|
142 | checkdep_svr4 "SUNWPython"
|
---|
143 | checkdep_svr4 "SUNWPython-devel"
|
---|
144 | checkdep_svr4 "SUNWuiu8"
|
---|
145 | else
|
---|
146 | PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
|
---|
147 | fi
|
---|
148 |
|
---|
149 | if test "$PKG_MISSING_IPS" != "" && test "$PKG_MISSING_SVR4" != ""; then
|
---|
150 | if test ! -x "$BIN_PKG" && test ! -x "$BIN_PKGINFO"; then
|
---|
151 | errorprint "Missing or non-executable binaries: pkg ($BIN_PKG) and pkginfo ($BIN_PKGINFO)."
|
---|
152 | errorprint "Cannot check for dependencies."
|
---|
153 | errorprint ""
|
---|
154 | errorprint "Please install one of the required packaging system."
|
---|
155 | exit 1
|
---|
156 | fi
|
---|
157 | errorprint "Missing packages: "
|
---|
158 | errorprint "IPS : $PKG_MISSING_IPS"
|
---|
159 | errorprint "SVr4: $PKG_MISSING_SVR4"
|
---|
160 | errorprint ""
|
---|
161 | errorprint "Please install either the IPS or SVr4 packages before installing VirtualBox."
|
---|
162 | exit 1
|
---|
163 | else
|
---|
164 | infoprint "Done."
|
---|
165 | fi
|
---|
166 |
|
---|
167 | # Nothing more to do for remote installs
|
---|
168 | if test "$REMOTE_INST" -eq 1; then
|
---|
169 | exit 0
|
---|
170 | fi
|
---|
171 |
|
---|
172 | # Check & disable running services
|
---|
173 | disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
|
---|
174 | disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
|
---|
175 | disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
|
---|
176 | disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
|
---|
177 |
|
---|
178 | # Check if VBoxSVC is currently running
|
---|
179 | VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
|
---|
180 | if test ! -z "$VBOXSVC_PID" && test "$VBOXSVC_PID" -ge 0; then
|
---|
181 | errorprint "VirtualBox's VBoxSVC (pid $VBOXSVC_PID) still appears to be running."
|
---|
182 | abort_error
|
---|
183 | fi
|
---|
184 |
|
---|
185 | # Check if VBoxNetDHCP is currently running
|
---|
186 | VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
|
---|
187 | if test ! -z "$VBOXNETDHCP_PID" && test "$VBOXNETDHCP_PID" -ge 0; then
|
---|
188 | errorprint "VirtualBox's VBoxNetDHCP (pid $VBOXNETDHCP_PID) still appears to be running."
|
---|
189 | abort_error
|
---|
190 | fi
|
---|
191 |
|
---|
192 | # Check if VBoxNetNAT is currently running
|
---|
193 | VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
|
---|
194 | if test ! -z "$VBOXNETNAT_PID" && test "$VBOXNETNAT_PID" -ge 0; then
|
---|
195 | errorprint "VirtualBox's VBoxNetNAT (pid $VBOXNETNAT_PID) still appears to be running."
|
---|
196 | abort_error
|
---|
197 | fi
|
---|
198 |
|
---|
199 | # Check if vboxnet is still plumbed, if so try unplumb it
|
---|
200 | BIN_IFCONFIG=`which ifconfig 2> /dev/null`
|
---|
201 | if test -x "$BIN_IFCONFIG"; then
|
---|
202 | vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
|
---|
203 | if test "$?" -eq 0; then
|
---|
204 | infoprint "VirtualBox NetAdapter is still plumbed"
|
---|
205 | infoprint "Trying to remove old NetAdapter..."
|
---|
206 | $BIN_IFCONFIG vboxnet0 unplumb
|
---|
207 | if test "$?" -ne 0; then
|
---|
208 | errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
|
---|
209 | abort_error
|
---|
210 | fi
|
---|
211 | fi
|
---|
212 | vboxnetup=`$BIN_IFCONFIG vboxnet0 inet6 >/dev/null 2>&1`
|
---|
213 | if test "$?" -eq 0; then
|
---|
214 | infoprint "VirtualBox NetAdapter (Ipv6) is still plumbed"
|
---|
215 | infoprint "Trying to remove old NetAdapter..."
|
---|
216 | $BIN_IFCONFIG vboxnet0 inet6 unplumb
|
---|
217 | if test "$?" -ne 0; then
|
---|
218 | errorprint "VirtualBox NetAdapter 'vboxnet0' IPv6 couldn't be unplumbed (probably in use)."
|
---|
219 | abort_error
|
---|
220 | fi
|
---|
221 | fi
|
---|
222 | fi
|
---|
223 |
|
---|
224 | # Make sure that SMF has finished removing any services left over from a
|
---|
225 | # previous installation which may interfere with installing new ones.
|
---|
226 | # This is only relevant on Solaris 11 for SysV packages.
|
---|
227 | #
|
---|
228 | # See BugDB 14838646 for the original problem and @bugref{7866} for
|
---|
229 | # follow up fixes.
|
---|
230 | for i in 1 2 3 4 5 6 7 8 9 10; do
|
---|
231 | $BIN_SVCS -H "svc:/application/virtualbox/autostart" >/dev/null 2>&1 ||
|
---|
232 | $BIN_SVCS -H "svc:/application/virtualbox/webservice" >/dev/null 2>&1 ||
|
---|
233 | $BIN_SVCS -H "svc:/application/virtualbox/zoneaccess" >/dev/null 2>&1 ||
|
---|
234 | $BIN_SVCS -H "svc:/application/virtualbox/balloonctrl" >/dev/null 2>&1 || break
|
---|
235 | if test "${i}" = "1"; then
|
---|
236 | printf "Waiting for services from previous installation to be removed."
|
---|
237 | elif test "${i}" = "10"; then
|
---|
238 | printf "\nWarning!!! Some service(s) still appears to be present"
|
---|
239 | else
|
---|
240 | printf "."
|
---|
241 | fi
|
---|
242 | sleep 1
|
---|
243 | done
|
---|
244 | test "${i}" = "1" || printf "\n"
|
---|
245 |
|
---|
246 | exit 0
|
---|
247 |
|
---|