1 | #!/bin/sh
|
---|
2 | # $Id: checkinstall.sh 56147 2015-05-29 11:36:27Z 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_svr4"
|
---|
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 |
|
---|
66 | disable_service()
|
---|
67 | {
|
---|
68 | if test -z "$1" || test -z "$2"; then
|
---|
69 | errorprint "Missing argument to disable_service"
|
---|
70 | return 1
|
---|
71 | fi
|
---|
72 | servicefound=`$BIN_SVCS -H "$1" 2> /dev/null | grep '^online'`
|
---|
73 | if test ! -z "$servicefound"; then
|
---|
74 | infoprint "$2 ($1) is still enabled. Disabling..."
|
---|
75 | $BIN_SVCADM disable -s "$1"
|
---|
76 | # Don't delete the service, handled by manifest class action
|
---|
77 | # /usr/sbin/svccfg delete $1
|
---|
78 | fi
|
---|
79 | }
|
---|
80 |
|
---|
81 | #
|
---|
82 | # Begin execution
|
---|
83 | #
|
---|
84 |
|
---|
85 | # Nothing to check for remote install
|
---|
86 | REMOTE_INST=0
|
---|
87 | if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
|
---|
88 | BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
|
---|
89 | REMOTE_INST=1
|
---|
90 | fi
|
---|
91 |
|
---|
92 | # Nothing to check for non-global zones
|
---|
93 | currentzone=`zonename`
|
---|
94 | if test "$currentzone" != "global"; then
|
---|
95 | exit 0
|
---|
96 | fi
|
---|
97 |
|
---|
98 | PKG_MISSING_IPS=""
|
---|
99 | PKG_MISSING_SVR4=""
|
---|
100 | BIN_PKGINFO=`which pkginfo 2> /dev/null`
|
---|
101 | BIN_PKG=`which pkg 2> /dev/null`
|
---|
102 | BIN_SVCS=`which svcs 2> /dev/null`
|
---|
103 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
104 |
|
---|
105 | # Check if our binaries are fine
|
---|
106 | if test ! -x "$BIN_SVCS"; then
|
---|
107 | errorprint "Missing or non-executable binary: svcs ($BIN_SVCS)."
|
---|
108 | exit 1
|
---|
109 | fi
|
---|
110 | if test ! -x "$BIN_SVCADM"; then
|
---|
111 | errorprint "Missing or non-executable binary: svcadm ($BIN_SVCADM)."
|
---|
112 | exit 1
|
---|
113 | fi
|
---|
114 |
|
---|
115 | infoprint "Checking package dependencies..."
|
---|
116 |
|
---|
117 | if test -x "$BIN_PKG"; then
|
---|
118 | checkdep_ips "runtime/python-26"
|
---|
119 | checkdep_ips "system/library/iconv/utf-8"
|
---|
120 | else
|
---|
121 | PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8"
|
---|
122 | fi
|
---|
123 | if test -x "$BIN_PKGINFO"; then
|
---|
124 | checkdep_svr4 "SUNWPython"
|
---|
125 | checkdep_svr4 "SUNWPython-devel"
|
---|
126 | checkdep_svr4 "SUNWuiu8"
|
---|
127 | else
|
---|
128 | PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
|
---|
129 | fi
|
---|
130 |
|
---|
131 | if test "$PKG_MISSING_IPS" != "" && test "$PKG_MISSING_SVR4" != ""; then
|
---|
132 | if test ! -x "$BIN_PKG" && test ! -x "$BIN_PKGINFO"; then
|
---|
133 | errorprint "Missing or non-executable binaries: pkg ($BIN_PKG) and pkginfo ($BIN_PKGINFO)."
|
---|
134 | errorprint "Cannot check for dependencies."
|
---|
135 | errorprint ""
|
---|
136 | errorprint "Please install one of the required packaging system."
|
---|
137 | exit 1
|
---|
138 | fi
|
---|
139 | errorprint "Missing packages: "
|
---|
140 | errorprint "IPS : $PKG_MISSING_IPS"
|
---|
141 | errorprint "SVr4: $PKG_MISSING_SVR4"
|
---|
142 | errorprint ""
|
---|
143 | errorprint "Please install either the IPS or SVr4 packages before installing VirtualBox."
|
---|
144 | exit 1
|
---|
145 | else
|
---|
146 | infoprint "Done."
|
---|
147 | fi
|
---|
148 |
|
---|
149 | # Nothing more to do for remote installs
|
---|
150 | if test "$REMOTE_INST" -eq 1; then
|
---|
151 | exit 0
|
---|
152 | fi
|
---|
153 |
|
---|
154 | # Check & disable running services
|
---|
155 | disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
|
---|
156 | disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
|
---|
157 | disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
|
---|
158 | disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
|
---|
159 |
|
---|
160 | # Check if VBoxSVC is currently running
|
---|
161 | VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
|
---|
162 | if test ! -z "$VBOXSVC_PID" && test "$VBOXSVC_PID" -ge 0; then
|
---|
163 | errorprint "VirtualBox's VBoxSVC (pid $VBOXSVC_PID) still appears to be running."
|
---|
164 | abort_error
|
---|
165 | fi
|
---|
166 |
|
---|
167 | # Check if VBoxNetDHCP is currently running
|
---|
168 | VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
|
---|
169 | if test ! -z "$VBOXNETDHCP_PID" && test "$VBOXNETDHCP_PID" -ge 0; then
|
---|
170 | errorprint "VirtualBox's VBoxNetDHCP (pid $VBOXNETDHCP_PID) still appears to be running."
|
---|
171 | abort_error
|
---|
172 | fi
|
---|
173 |
|
---|
174 | # Check if VBoxNetNAT is currently running
|
---|
175 | VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
|
---|
176 | if test ! -z "$VBOXNETNAT_PID" && test "$VBOXNETNAT_PID" -ge 0; then
|
---|
177 | errorprint "VirtualBox's VBoxNetNAT (pid $VBOXNETNAT_PID) still appears to be running."
|
---|
178 | abort_error
|
---|
179 | fi
|
---|
180 |
|
---|
181 | # Check if vboxnet is still plumbed, if so try unplumb it
|
---|
182 | BIN_IFCONFIG=`which ifconfig 2> /dev/null`
|
---|
183 | if test -x "$BIN_IFCONFIG"; then
|
---|
184 | vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
|
---|
185 | if test "$?" -eq 0; then
|
---|
186 | infoprint "VirtualBox NetAdapter is still plumbed"
|
---|
187 | infoprint "Trying to remove old NetAdapter..."
|
---|
188 | $BIN_IFCONFIG vboxnet0 unplumb
|
---|
189 | if test "$?" -ne 0; then
|
---|
190 | errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
|
---|
191 | abort_error
|
---|
192 | fi
|
---|
193 | fi
|
---|
194 | vboxnetup=`$BIN_IFCONFIG vboxnet0 inet6 >/dev/null 2>&1`
|
---|
195 | if test "$?" -eq 0; then
|
---|
196 | infoprint "VirtualBox NetAdapter (Ipv6) is still plumbed"
|
---|
197 | infoprint "Trying to remove old NetAdapter..."
|
---|
198 | $BIN_IFCONFIG vboxnet0 inet6 unplumb
|
---|
199 | if test "$?" -ne 0; then
|
---|
200 | errorprint "VirtualBox NetAdapter 'vboxnet0' IPv6 couldn't be unplumbed (probably in use)."
|
---|
201 | abort_error
|
---|
202 | fi
|
---|
203 | fi
|
---|
204 | fi
|
---|
205 |
|
---|
206 | # Make sure that SMF has finished removing any services left over from a
|
---|
207 | # previous installation which may interfere with installing new ones.
|
---|
208 | # This is only relevant on Solaris 11 for SysV packages.
|
---|
209 | #
|
---|
210 | # See BugDB 14838646 for the original problem and @bugref{7866} for
|
---|
211 | # follow up fixes.
|
---|
212 | for i in 1 2 3 4 5 6 7 8 9 10; do
|
---|
213 | $BIN_SVCS -H "svc:/application/virtualbox/autostart" >/dev/null 2>&1 ||
|
---|
214 | $BIN_SVCS -H "svc:/application/virtualbox/webservice" >/dev/null 2>&1 ||
|
---|
215 | $BIN_SVCS -H "svc:/application/virtualbox/zoneaccess" >/dev/null 2>&1 ||
|
---|
216 | $BIN_SVCS -H "svc:/application/virtualbox/balloonctrl" >/dev/null 2>&1 || break
|
---|
217 | if test "${i}" = "1"; then
|
---|
218 | printf "Waiting for services from previous installation to be removed."
|
---|
219 | elif test "${i}" = "10"; then
|
---|
220 | printf "\nWarning!!! Some service(s) still appears to be present"
|
---|
221 | else
|
---|
222 | printf "."
|
---|
223 | fi
|
---|
224 | sleep 1
|
---|
225 | done
|
---|
226 | test "${i}" = "1" || printf "\n"
|
---|
227 |
|
---|
228 | exit 0
|
---|
229 |
|
---|