VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/checkinstall.sh@ 56874

Last change on this file since 56874 was 56564, checked in by vboxsync, 10 years ago

Solaris/Installer: Fix for Solaris 12 renaming iconv/utf-8 package.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
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
20infoprint()
21{
22 echo 1>&2 "$1"
23}
24
25errorprint()
26{
27 echo 1>&2 "## $1"
28}
29
30abort_error()
31{
32 errorprint "Please close all VirtualBox processes and re-run this installer."
33 exit 1
34}
35
36checkdep_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
50checkdep_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
65checkdep_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
84disable_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
104REMOTE_INST=0
105if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
106 BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
107 REMOTE_INST=1
108fi
109
110# Nothing to check for non-global zones
111currentzone=`zonename`
112if test "$currentzone" != "global"; then
113 exit 0
114fi
115
116PKG_MISSING_IPS=""
117PKG_MISSING_SVR4=""
118BIN_PKGINFO=`which pkginfo 2> /dev/null`
119BIN_PKG=`which pkg 2> /dev/null`
120BIN_SVCS=`which svcs 2> /dev/null`
121BIN_SVCADM=/usr/sbin/svcadm
122
123# Check if our binaries are fine
124if test ! -x "$BIN_SVCS"; then
125 errorprint "Missing or non-executable binary: svcs ($BIN_SVCS)."
126 exit 1
127fi
128if test ! -x "$BIN_SVCADM"; then
129 errorprint "Missing or non-executable binary: svcadm ($BIN_SVCADM)."
130 exit 1
131fi
132
133infoprint "Checking package dependencies..."
134
135if 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"
138else
139 PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8"
140fi
141if test -x "$BIN_PKGINFO"; then
142 checkdep_svr4 "SUNWPython"
143 checkdep_svr4 "SUNWPython-devel"
144 checkdep_svr4 "SUNWuiu8"
145else
146 PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
147fi
148
149if 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
163else
164 infoprint "Done."
165fi
166
167# Nothing more to do for remote installs
168if test "$REMOTE_INST" -eq 1; then
169 exit 0
170fi
171
172# Check & disable running services
173disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
174disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
175disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
176disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
177
178# Check if VBoxSVC is currently running
179VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
180if 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
183fi
184
185# Check if VBoxNetDHCP is currently running
186VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
187if 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
190fi
191
192# Check if VBoxNetNAT is currently running
193VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
194if 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
197fi
198
199# Check if vboxnet is still plumbed, if so try unplumb it
200BIN_IFCONFIG=`which ifconfig 2> /dev/null`
201if 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
222fi
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.
230for 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
243done
244test "${i}" = "1" || printf "\n"
245
246exit 0
247
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette