1 | #!/bin/sh
|
---|
2 | # $Id: checkinstall.sh 93115 2022-01-01 11:31:46Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | #
|
---|
5 | # VirtualBox checkinstall script for Solaris.
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2009-2022 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 | # find_bin_path()
|
---|
100 | # !! failure is always fatal
|
---|
101 | find_bin_path()
|
---|
102 | {
|
---|
103 | if test -z "$1"; then
|
---|
104 | errorprint "missing argument to find_bin_path()"
|
---|
105 | exit 1
|
---|
106 | fi
|
---|
107 |
|
---|
108 | binfilename=`basename $1`
|
---|
109 | binfilepath=`which $binfilename 2> /dev/null`
|
---|
110 | if test -x "$binfilepath"; then
|
---|
111 | echo "$binfilepath"
|
---|
112 | return 0
|
---|
113 | else
|
---|
114 | errorprint "$1 missing or is not an executable"
|
---|
115 | exit 1
|
---|
116 | fi
|
---|
117 | }
|
---|
118 |
|
---|
119 | # find_bins()
|
---|
120 | # !! failure is always fatal
|
---|
121 | find_mandatory_bins()
|
---|
122 | {
|
---|
123 | # Search only for binaries that might be in different locations
|
---|
124 | if test ! -x "$BIN_SVCS"; then
|
---|
125 | BIN_SVCS=`find_bin_path "$BIN_SVCS"`
|
---|
126 | fi
|
---|
127 |
|
---|
128 | if test ! -x "$BIN_SVCADM"; then
|
---|
129 | BIN_SVCADM=`find_bin_path "$BIN_SVCADM"`
|
---|
130 | fi
|
---|
131 | }
|
---|
132 |
|
---|
133 |
|
---|
134 | #
|
---|
135 | # Begin execution
|
---|
136 | #
|
---|
137 |
|
---|
138 | # Nothing to check for remote install
|
---|
139 | REMOTE_INST=0
|
---|
140 | if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
|
---|
141 | BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
|
---|
142 | REMOTE_INST=1
|
---|
143 | fi
|
---|
144 |
|
---|
145 | # Nothing to check for non-global zones
|
---|
146 | currentzone=`zonename`
|
---|
147 | if test "x$currentzone" != "xglobal"; then
|
---|
148 | exit 0
|
---|
149 | fi
|
---|
150 |
|
---|
151 | PKG_MISSING_IPS=""
|
---|
152 | PKG_MISSING_SVR4=""
|
---|
153 | BIN_PKGINFO=/usr/bin/pkginfo
|
---|
154 | BIN_PKG=/usr/bin/pkg
|
---|
155 | BIN_SVCS=/usr/bin/svcs
|
---|
156 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
157 |
|
---|
158 | # Check non-optional binaries
|
---|
159 | find_mandatory_bins
|
---|
160 |
|
---|
161 | infoprint "Checking package dependencies..."
|
---|
162 |
|
---|
163 | if test -x "$BIN_PKG"; then
|
---|
164 | checkdep_ips_either "runtime/python-26" "runtime/python-27"
|
---|
165 | checkdep_ips_either "system/library/iconv/utf-8" "system/library/iconv/iconv-core"
|
---|
166 | checkdep_ips_either "system/library/gcc/gcc-c++-runtime" "system/library/gcc-45-runtime"
|
---|
167 | checkdep_ips_either "system/library/gcc/gcc-c-runtime" "system/library/gcc-45-runtime"
|
---|
168 | else
|
---|
169 | PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8 system/library/gcc/gcc-c++-runtime system/library/gcc/gcc-c-runtime"
|
---|
170 | fi
|
---|
171 | if test -x "$BIN_PKGINFO"; then
|
---|
172 | checkdep_svr4 "SUNWPython"
|
---|
173 | checkdep_svr4 "SUNWPython-devel"
|
---|
174 | checkdep_svr4 "SUNWuiu8"
|
---|
175 | else
|
---|
176 | PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
|
---|
177 | fi
|
---|
178 |
|
---|
179 | if test "x$PKG_MISSING_IPS" != "x" && test "x$PKG_MISSING_SVR4" != "x"; then
|
---|
180 | if test ! -x "$BIN_PKG" && test ! -x "$BIN_PKGINFO"; then
|
---|
181 | errorprint "Missing or non-executable binaries: pkg ($BIN_PKG) and pkginfo ($BIN_PKGINFO)."
|
---|
182 | errorprint "Cannot check for dependencies."
|
---|
183 | errorprint ""
|
---|
184 | errorprint "Please install one of the required packaging system."
|
---|
185 | exit 1
|
---|
186 | fi
|
---|
187 | errorprint "Missing packages: "
|
---|
188 | errorprint "IPS : $PKG_MISSING_IPS"
|
---|
189 | errorprint "SVr4: $PKG_MISSING_SVR4"
|
---|
190 | errorprint ""
|
---|
191 | errorprint "Please install either the IPS or SVr4 packages before installing VirtualBox."
|
---|
192 | exit 1
|
---|
193 | else
|
---|
194 | infoprint "Done."
|
---|
195 | fi
|
---|
196 |
|
---|
197 | # Nothing more to do for remote installs
|
---|
198 | if test "$REMOTE_INST" -eq 1; then
|
---|
199 | exit 0
|
---|
200 | fi
|
---|
201 |
|
---|
202 | # Check & disable running services
|
---|
203 | disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
|
---|
204 | disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
|
---|
205 | disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
|
---|
206 | disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
|
---|
207 |
|
---|
208 | # Check if VBoxSVC is currently running
|
---|
209 | VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
|
---|
210 | if test ! -z "$VBOXSVC_PID" && test "$VBOXSVC_PID" -ge 0; then
|
---|
211 | errorprint "VirtualBox's VBoxSVC (pid $VBOXSVC_PID) still appears to be running."
|
---|
212 | abort_error
|
---|
213 | fi
|
---|
214 |
|
---|
215 | # Check if VBoxNetDHCP is currently running
|
---|
216 | VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
|
---|
217 | if test ! -z "$VBOXNETDHCP_PID" && test "$VBOXNETDHCP_PID" -ge 0; then
|
---|
218 | errorprint "VirtualBox's VBoxNetDHCP (pid $VBOXNETDHCP_PID) still appears to be running."
|
---|
219 | abort_error
|
---|
220 | fi
|
---|
221 |
|
---|
222 | # Check if VBoxNetNAT is currently running
|
---|
223 | VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
|
---|
224 | if test ! -z "$VBOXNETNAT_PID" && test "$VBOXNETNAT_PID" -ge 0; then
|
---|
225 | errorprint "VirtualBox's VBoxNetNAT (pid $VBOXNETNAT_PID) still appears to be running."
|
---|
226 | abort_error
|
---|
227 | fi
|
---|
228 |
|
---|
229 | # Check if vboxnet is still plumbed, if so try unplumb it
|
---|
230 | BIN_IFCONFIG=`which ifconfig 2> /dev/null`
|
---|
231 | if test -x "$BIN_IFCONFIG"; then
|
---|
232 | vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
|
---|
233 | if test "$?" -eq 0; then
|
---|
234 | infoprint "VirtualBox NetAdapter is still plumbed"
|
---|
235 | infoprint "Trying to remove old NetAdapter..."
|
---|
236 | $BIN_IFCONFIG vboxnet0 unplumb
|
---|
237 | if test "$?" -ne 0; then
|
---|
238 | errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
|
---|
239 | abort_error
|
---|
240 | fi
|
---|
241 | fi
|
---|
242 | vboxnetup=`$BIN_IFCONFIG vboxnet0 inet6 >/dev/null 2>&1`
|
---|
243 | if test "$?" -eq 0; then
|
---|
244 | infoprint "VirtualBox NetAdapter (Ipv6) is still plumbed"
|
---|
245 | infoprint "Trying to remove old NetAdapter..."
|
---|
246 | $BIN_IFCONFIG vboxnet0 inet6 unplumb
|
---|
247 | if test "$?" -ne 0; then
|
---|
248 | errorprint "VirtualBox NetAdapter 'vboxnet0' IPv6 couldn't be unplumbed (probably in use)."
|
---|
249 | abort_error
|
---|
250 | fi
|
---|
251 | fi
|
---|
252 | fi
|
---|
253 |
|
---|
254 | # Make sure that SMF has finished removing any services left over from a
|
---|
255 | # previous installation which may interfere with installing new ones.
|
---|
256 | # This is only relevant on Solaris 11 for SysV packages.
|
---|
257 | #
|
---|
258 | # See BugDB 14838646 for the original problem and @bugref{7866} for
|
---|
259 | # follow up fixes.
|
---|
260 | for i in 1 2 3 4 5 6 7 8 9 10; do
|
---|
261 | $BIN_SVCS -H "svc:/application/virtualbox/autostart" >/dev/null 2>&1 ||
|
---|
262 | $BIN_SVCS -H "svc:/application/virtualbox/webservice" >/dev/null 2>&1 ||
|
---|
263 | $BIN_SVCS -H "svc:/application/virtualbox/zoneaccess" >/dev/null 2>&1 ||
|
---|
264 | $BIN_SVCS -H "svc:/application/virtualbox/balloonctrl" >/dev/null 2>&1 || break
|
---|
265 | if test "${i}" = "1"; then
|
---|
266 | printf "Waiting for services from previous installation to be removed."
|
---|
267 | elif test "${i}" = "10"; then
|
---|
268 | printf "\nWarning!!! Some service(s) still appears to be present"
|
---|
269 | else
|
---|
270 | printf "."
|
---|
271 | fi
|
---|
272 | sleep 1
|
---|
273 | done
|
---|
274 | test "${i}" = "1" || printf "\n"
|
---|
275 |
|
---|
276 | exit 0
|
---|
277 |
|
---|