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