1*b1cdbd2cSJim Jagielski#!/bin/sh 2*b1cdbd2cSJim Jagielski# ************************************************************* 3*b1cdbd2cSJim Jagielski# 4*b1cdbd2cSJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 5*b1cdbd2cSJim Jagielski# or more contributor license agreements. See the NOTICE file 6*b1cdbd2cSJim Jagielski# distributed with this work for additional information 7*b1cdbd2cSJim Jagielski# regarding copyright ownership. The ASF licenses this file 8*b1cdbd2cSJim Jagielski# to you under the Apache License, Version 2.0 (the 9*b1cdbd2cSJim Jagielski# "License"); you may not use this file except in compliance 10*b1cdbd2cSJim Jagielski# with the License. You may obtain a copy of the License at 11*b1cdbd2cSJim Jagielski# 12*b1cdbd2cSJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 13*b1cdbd2cSJim Jagielski# 14*b1cdbd2cSJim Jagielski# Unless required by applicable law or agreed to in writing, 15*b1cdbd2cSJim Jagielski# software distributed under the License is distributed on an 16*b1cdbd2cSJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*b1cdbd2cSJim Jagielski# KIND, either express or implied. See the License for the 18*b1cdbd2cSJim Jagielski# specific language governing permissions and limitations 19*b1cdbd2cSJim Jagielski# under the License. 20*b1cdbd2cSJim Jagielski# 21*b1cdbd2cSJim Jagielski# ************************************************************* 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim JagielskiMYUID=`id | sed "s/(.*//g" | sed "s/.*=//"` 24*b1cdbd2cSJim Jagielski 25*b1cdbd2cSJim Jagielskiif [ $MYUID -ne 0 ] 26*b1cdbd2cSJim Jagielskithen 27*b1cdbd2cSJim Jagielski echo You need to have super-user rights to install this language package 28*b1cdbd2cSJim Jagielski exit 1 29*b1cdbd2cSJim Jagielskifi 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielskilinenum=LINENUMBERPLACEHOLDER 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski# Determining current platform 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielskiplatform=`uname -s` 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielskicase $platform in 38*b1cdbd2cSJim JagielskiSunOS) 39*b1cdbd2cSJim Jagielski tail_prog="tail" 40*b1cdbd2cSJim Jagielski ;; 41*b1cdbd2cSJim JagielskiLinux) 42*b1cdbd2cSJim Jagielski tail_prog="tail -n" 43*b1cdbd2cSJim Jagielski ;; 44*b1cdbd2cSJim Jagielski*) 45*b1cdbd2cSJim Jagielski tail_prog="tail" 46*b1cdbd2cSJim Jagielski ;; 47*b1cdbd2cSJim Jagielskiesac 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim Jagielskimore << "EOF" 50*b1cdbd2cSJim JagielskiLICENSEFILEPLACEHOLDER 51*b1cdbd2cSJim JagielskiEOF 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielskiagreed= 54*b1cdbd2cSJim Jagielskiwhile [ x$agreed = x ]; do 55*b1cdbd2cSJim Jagielski echo 56*b1cdbd2cSJim Jagielski echo "Do you agree to the above license terms? [yes or no] " 57*b1cdbd2cSJim Jagielski read reply leftover 58*b1cdbd2cSJim Jagielski case $reply in 59*b1cdbd2cSJim Jagielski y* | Y*) 60*b1cdbd2cSJim Jagielski agreed=1;; 61*b1cdbd2cSJim Jagielski n* | N*) 62*b1cdbd2cSJim Jagielski echo "If you don't agree to the license you can't install this software"; 63*b1cdbd2cSJim Jagielski exit 1;; 64*b1cdbd2cSJim Jagielski esac 65*b1cdbd2cSJim Jagielskidone 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielskicase $platform in 68*b1cdbd2cSJim JagielskiSunOS) 69*b1cdbd2cSJim Jagielski SEARCHPACKAGENAME="BASISPACKAGEPREFIXPLACEHOLDEROOOBASEVERSIONPLACEHOLDER-core01" 70*b1cdbd2cSJim Jagielski echo 71*b1cdbd2cSJim Jagielski echo "Searching for the FULLPRODUCTNAMELONGPLACEHOLDER installation ..." 72*b1cdbd2cSJim Jagielski PACKAGENAME=`pkginfo -x | grep $SEARCHPACKAGENAME | sed "s/ .*//"` 73*b1cdbd2cSJim Jagielski if [ "x$PACKAGENAME" != "x" ] 74*b1cdbd2cSJim Jagielski then 75*b1cdbd2cSJim Jagielski PRODUCTINSTALLLOCATION="`pkginfo -r $PACKAGENAME`" 76*b1cdbd2cSJim Jagielski else 77*b1cdbd2cSJim Jagielski echo "FULLPRODUCTNAMELONGPLACEHOLDER not installed (no package $SEARCHPACKAGENAME installed)" 78*b1cdbd2cSJim Jagielski exit 1 79*b1cdbd2cSJim Jagielski fi 80*b1cdbd2cSJim Jagielski ;; 81*b1cdbd2cSJim JagielskiLinux) 82*b1cdbd2cSJim Jagielski SEARCHPACKAGENAME="BASISPACKAGEPREFIXPLACEHOLDEROOOBASEVERSIONPLACEHOLDER-core01" 83*b1cdbd2cSJim Jagielski FIXPATH="/apachopenoffice" 84*b1cdbd2cSJim Jagielski echo 85*b1cdbd2cSJim Jagielski echo "Searching for the FULLPRODUCTNAMELONGPLACEHOLDER installation ..." 86*b1cdbd2cSJim Jagielski RPMNAME=`rpm -qa | grep $SEARCHPACKAGENAME` 87*b1cdbd2cSJim Jagielski if [ "x$RPMNAME" != "x" ] 88*b1cdbd2cSJim Jagielski then 89*b1cdbd2cSJim Jagielski PRODUCTINSTALLLOCATION="`rpm -ql $RPMNAME | head -n 1`" 90*b1cdbd2cSJim Jagielski else 91*b1cdbd2cSJim Jagielski echo "FULLPRODUCTNAMELONGPLACEHOLDER not installed (no package $SEARCHPACKAGENAME installed)" 92*b1cdbd2cSJim Jagielski exit 1 93*b1cdbd2cSJim Jagielski fi 94*b1cdbd2cSJim Jagielski PRODUCTINSTALLLOCATION=`echo $PRODUCTINSTALLLOCATION | sed "s#${FIXPATH}##"` 95*b1cdbd2cSJim Jagielski ;; 96*b1cdbd2cSJim Jagielski*) 97*b1cdbd2cSJim Jagielski echo "Unsupported platform" 98*b1cdbd2cSJim Jagielski exit 1 99*b1cdbd2cSJim Jagielski ;; 100*b1cdbd2cSJim Jagielskiesac 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski# Asking for the installation directory 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski# echo 105*b1cdbd2cSJim Jagielski# echo "Where do you want to install the language pack ? [$PRODUCTINSTALLLOCATION] " 106*b1cdbd2cSJim Jagielski# read reply leftover 107*b1cdbd2cSJim Jagielski# if [ "x$reply" != "x" ] 108*b1cdbd2cSJim Jagielski# then 109*b1cdbd2cSJim Jagielski# PRODUCTINSTALLLOCATION="$reply" 110*b1cdbd2cSJim Jagielski# fi 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski# Unpacking 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielskioutdir=/var/tmp/install_$$ 115*b1cdbd2cSJim Jagielskimkdir $outdir 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski#diskSpace=`df -k $outdir | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'` 118*b1cdbd2cSJim Jagielski#if [ $diskSpace -lt $diskSpaceRequired ]; then 119*b1cdbd2cSJim Jagielski# printf "You will need atleast %s kBytes of Disk Free\n" $diskSpaceRequired 120*b1cdbd2cSJim Jagielski# printf "Please free up the required Disk Space and try again\n" 121*b1cdbd2cSJim Jagielski# exit 3 122*b1cdbd2cSJim Jagielski#fi 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielskitrap 'rm -rf $outdir; exit 1' HUP INT QUIT TERM 125*b1cdbd2cSJim Jagielskiecho "Unpacking and installing..." 126*b1cdbd2cSJim Jagielski 127*b1cdbd2cSJim Jagielski#if [ -x /usr/bin/sum ] ; then 128*b1cdbd2cSJim Jagielski# echo "Checksumming..." 129*b1cdbd2cSJim Jagielski# 130*b1cdbd2cSJim Jagielski# sum=`/usr/bin/sum $outdir/$outname` 131*b1cdbd2cSJim Jagielski# index=1 132*b1cdbd2cSJim Jagielski# for s in $sum 133*b1cdbd2cSJim Jagielski# do 134*b1cdbd2cSJim Jagielski# case $index in 135*b1cdbd2cSJim Jagielski# 1) sum1=$s; 136*b1cdbd2cSJim Jagielski# index=2; 137*b1cdbd2cSJim Jagielski# ;; 138*b1cdbd2cSJim Jagielski# 2) sum2=$s; 139*b1cdbd2cSJim Jagielski# index=3; 140*b1cdbd2cSJim Jagielski# ;; 141*b1cdbd2cSJim Jagielski# esac 142*b1cdbd2cSJim Jagielski# done 143*b1cdbd2cSJim Jagielski# if expr $sum1 != <sum1replace> || expr $sum2 != <sum2replace> ; then 144*b1cdbd2cSJim Jagielski# echo "The download file appears to be corrupted. Please refer" 145*b1cdbd2cSJim Jagielski# echo "to the Troubleshooting section of the Installation" 146*b1cdbd2cSJim Jagielski# exit 1 147*b1cdbd2cSJim Jagielski# fi 148*b1cdbd2cSJim Jagielski#else 149*b1cdbd2cSJim Jagielski# echo "Can't find /usr/bin/sum to do checksum. Continuing anyway." 150*b1cdbd2cSJim Jagielski#fi 151*b1cdbd2cSJim Jagielski 152*b1cdbd2cSJim Jagielskicase $platform in 153*b1cdbd2cSJim JagielskiSunOS) 154*b1cdbd2cSJim Jagielski $tail_prog +$linenum $0 | gunzip | (cd $outdir; tar xvf -) 155*b1cdbd2cSJim Jagielski adminfile=$outdir/admin.$$ 156*b1cdbd2cSJim Jagielski echo "basedir=$PRODUCTINSTALLLOCATION" > $adminfile 157*b1cdbd2cSJim JagielskiINSTALLLINES 158*b1cdbd2cSJim Jagielski ;; 159*b1cdbd2cSJim JagielskiLinux) 160*b1cdbd2cSJim Jagielski $tail_prog +$linenum $0 | gunzip | (cd $outdir; tar xvf -) 161*b1cdbd2cSJim JagielskiINSTALLLINES 162*b1cdbd2cSJim Jagielski ;; 163*b1cdbd2cSJim Jagielski*) 164*b1cdbd2cSJim Jagielski echo "Unsupported platform" 165*b1cdbd2cSJim Jagielski exit 1 166*b1cdbd2cSJim Jagielski ;; 167*b1cdbd2cSJim Jagielskiesac 168*b1cdbd2cSJim Jagielski 169*b1cdbd2cSJim Jagielskirm -rf $outdir 170*b1cdbd2cSJim Jagielski 171*b1cdbd2cSJim Jagielskiecho "Done..." 172*b1cdbd2cSJim Jagielski 173*b1cdbd2cSJim Jagielskiexit 0 174