VirtualBox

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

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

Solaris/Installer: checkinstall cleanup.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
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
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_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
66disable_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
86REMOTE_INST=0
87if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
88 BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
89 REMOTE_INST=1
90fi
91
92# Nothing to check for non-global zones
93currentzone=`zonename`
94if test "$currentzone" != "global"; then
95 exit 0
96fi
97
98PKG_MISSING_IPS=""
99PKG_MISSING_SVR4=""
100BIN_PKGINFO=`which pkginfo 2> /dev/null`
101BIN_PKG=`which pkg 2> /dev/null`
102BIN_SVCS=`which svcs 2> /dev/null`
103BIN_SVCADM=/usr/sbin/svcadm
104
105# Check if our binaries are fine
106if test ! -x "$BIN_SVCS"; then
107 errorprint "Missing or non-executable binary: svcs ($BIN_SVCS)."
108 exit 1
109fi
110if test ! -x "$BIN_SVCADM"; then
111 errorprint "Missing or non-executable binary: svcadm ($BIN_SVCADM)."
112 exit 1
113fi
114
115infoprint "Checking package dependencies..."
116
117if test -x "$BIN_PKG"; then
118 checkdep_ips "runtime/python-26"
119 checkdep_ips "system/library/iconv/utf-8"
120else
121 PKG_MISSING_IPS="runtime/python-26 system/library/iconv/utf-8"
122fi
123if test -x "$BIN_PKGINFO"; then
124 checkdep_svr4 "SUNWPython"
125 checkdep_svr4 "SUNWPython-devel"
126 checkdep_svr4 "SUNWuiu8"
127else
128 PKG_MISSING_SVR4="SUNWPython SUNWPython-devel SUNWuiu8"
129fi
130
131if 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
145else
146 infoprint "Done."
147fi
148
149# Nothing more to do for remote installs
150if test "$REMOTE_INST" -eq 1; then
151 exit 0
152fi
153
154# Check & disable running services
155disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
156disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
157disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
158disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
159
160# Check if VBoxSVC is currently running
161VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
162if 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
165fi
166
167# Check if VBoxNetDHCP is currently running
168VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
169if 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
172fi
173
174# Check if VBoxNetNAT is currently running
175VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
176if 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
179fi
180
181# Check if vboxnet is still plumbed, if so try unplumb it
182BIN_IFCONFIG=`which ifconfig 2> /dev/null`
183if 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
204fi
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.
212for 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
225done
226test "${i}" = "1" || printf "\n"
227
228exit 0
229
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