5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Description: Download the driver package from the
25 # network, use pkg_check.sh to uncompress
26 # the package if the package is compressed,
27 # then use load_driver.sh to install the
31 # 3rd_drv_int.sh pkg_type download_url root_path
32 # $1 is for package type.(IPS, DU, SVR4, P5I, UNK)
33 # $2 is the driver download URL
34 # $3 is root path for installation, can be null.
48 if [ -s $f_dir_file ]; then
49 for f_dir
in $
(cat $f_dir_file); do
54 if [ -s $pkg_loc ]; then
55 d_name
=$
(echo $pkg_loc | cut
-d'/' -f3)
56 cd /tmp
; rm -rf $d_name
64 trap 'clean_up;exit 10' KILL INT
67 PATH
=/usr
/bin
:/usr
/sbin
:$PATH; export PATH
68 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:/usr
/ddu
/lib
; export LD_LIBRARY_PATH
71 # Confirm the correct number of commnad line argument
73 if (( $# < 2 )) ||
(( $# > 3 )); then
74 print
-u2 "\n $0: Wrong number of arguments provided..."
79 # Validate the arguments
83 IPS | DU | SVR4 | P5I | UNK
);;
84 *) print
-u2 "\n... $0: $1 is not valid."; exit 1;;
87 echo "$2" |
egrep -e \
88 "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))[\w\d:#%/;$()~_?\\-=\\\.&]*)" \
92 print
-u2 "\n... $0: $2 is not valid URL."
98 print
-u2 "\n... $0: $3 specified is not a valid path."
103 typeset
-r base_dir
=$
(dirname $0)
104 typeset pkg_type
="$1"
105 typeset
-r root_path
="$3"
107 print
-u1 "\nDownloading from URL $2 ..."
109 if [[ ! -x $base_dir/url_down.py
]]; then
110 print
-u2 "$base_dir/url_down.py not found."
114 typeset pkg_info pkg_type pkg_loc
115 typeset
-r f_dir_file
=/tmp
/f_dir_file_$$
119 while [ $try_time -le 5 ]; do
120 $base_dir/url_down.py download
"$2" > $f_dir_file
121 if [ $?
-ne 0 ]; then
124 while [ -d /proc
/${idle_time} ]; do
127 try_time
=$
((try_time
+ 1))
134 if [ $try_time -le 5 ] && [ -s $f_dir_file ]; then
135 for f_dir
in $
(cat $f_dir_file); do
136 7za t
"$f_dir" >/dev
/null
2>&1
137 if [ $?
-eq 0 ]; then
139 # For compressed data
141 if [[ ! -x $base_dir/pkg_check.sh
]]; then
142 print
-u2 "$base_dir/pkg_check.sh not found."
146 if [[ ! -x $base_dir/load_driver.sh
]]; then
147 print
-u2 "$base_dir/load_driver.sh not found."
151 pkg_info
=$
($base_dir/pkg_check.sh
$f_dir)
152 if [ $?
-eq 0 ] && [ ! -z $pkg_info ]; then
153 for i
in $pkg_info; do
154 pkg_type
=$
(echo $i | cut
-d'|' -f1)
155 pkg_loc
=$
(echo $i | cut
-d'|' -f2)
156 if [ ! -z $pkg_type ] && [ ! -z $pkg_loc ]; then
158 # Add quote for $pkg_loc for spaces in the variable
161 $base_dir/load_driver.sh
$pkg_type "$pkg_loc" $root_path
162 if [ $?
-ne 0 ]; then
163 print
-u2 "Error executing: $base_dir/load_driver.sh."
167 print
-u2 "Package type and location can not be null."
172 print
-u2 "Error executing: $base_dir/pkg_check.sh."
180 # Add quote for $f_dir for spaces in the variable
182 $base_dir/load_driver.sh
$pkg_type "$f_dir" $root_path
183 if [ $?
-ne 0 ]; then
184 print
-u2 "Error executing: $base_dir/load_driver.sh."
190 print
-u2 "\nDownload $2 failed!"