1#!/bin/bash
2# *************************************************************
3#
4#  Licensed to the Apache Software Foundation (ASF) under one
5#  or more contributor license agreements.  See the NOTICE file
6#  distributed with this work for additional information
7#  regarding copyright ownership.  The ASF licenses this file
8#  to you under the Apache License, Version 2.0 (the
9#  "License"); you may not use this file except in compliance
10#  with the License.  You may obtain a copy of the License at
11#
12#    http://www.apache.org/licenses/LICENSE-2.0
13#
14#  Unless required by applicable law or agreed to in writing,
15#  software distributed under the License is distributed on an
16#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17#  KIND, either express or implied.  See the License for the
18#  specific language governing permissions and limitations
19#  under the License.
20#
21# *************************************************************
22
23# Linux deinstallation
24# No parameter required, all RPMs listed in $HOME/.RPM_OFFICEDATABASE
25# will be removed.
26
27if [ $# -ne 1 ]
28then
29  echo
30  echo "Usage:" $0 "<office-installation-dir>"
31  echo "    <inst-destination-dir>: directory where the office to be removed is installed"
32  echo
33  exit 2
34fi
35
36INSTALLDIR=$1
37
38# Check for old style .RPM_OFFICEDATABASE first
39if [ -d ${INSTALLDIR}/.RPM_OFFICEDATABASE ]; then
40  RPM_DB_PATH=${INSTALLDIR}/.RPM_OFFICEDATABASE
41else
42  RPM_DB_PATH=${INSTALLDIR}/.RPM_DATABASE
43fi
44
45# the RPM_DB_PATH must be absolute
46if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
47  RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd`
48fi
49
50RPMLIST=`rpm --dbpath $RPM_DB_PATH --query --all`
51
52# Output ...
53clear
54echo "#########################################"
55echo "#     Deinstallation of Office RPMs     #"
56echo "#########################################"
57echo
58echo "Path to the RPM database: " $RPM_DB_PATH
59echo "RPMs to deinstall:"
60echo "$RPMLIST"
61echo "===================================================================="
62echo
63
64# Restore original bootstraprc
65mv -f $1/program/bootstraprc.orig $1/program/bootstraprc
66
67rpm --dbpath $RPM_DB_PATH --erase $RPMLIST || exit 2
68
69echo "Removing RPM database ..."
70rm -rf $RPM_DB_PATH
71
72echo
73echo "Deinstallation done."
74
75exit 0
76