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