1e4af8f11SPedro Giffuni#!/bin/sh
2*9f22d7c2SAndrew Rist# *************************************************************
3*9f22d7c2SAndrew Rist#
4*9f22d7c2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*9f22d7c2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*9f22d7c2SAndrew Rist#  distributed with this work for additional information
7*9f22d7c2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*9f22d7c2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*9f22d7c2SAndrew Rist#  "License"); you may not use this file except in compliance
10*9f22d7c2SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*9f22d7c2SAndrew Rist#
12*9f22d7c2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*9f22d7c2SAndrew Rist#
14*9f22d7c2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*9f22d7c2SAndrew Rist#  software distributed under the License is distributed on an
16*9f22d7c2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*9f22d7c2SAndrew Rist#  KIND, either express or implied.  See the License for the
18*9f22d7c2SAndrew Rist#  specific language governing permissions and limitations
19*9f22d7c2SAndrew Rist#  under the License.
20*9f22d7c2SAndrew Rist#
21*9f22d7c2SAndrew Rist# *************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir# First parameter: Root path that will be removed
24cdf0e10cSrcweir# MY_ROOT=/export/home/is/root
25cdf0e10cSrcweir
26cdf0e10cSrcweirif [ $# -ne 1 -o -z "$1" ]
27cdf0e10cSrcweirthen
28cdf0e10cSrcweir  echo "One parameter required"
29cdf0e10cSrcweir  echo "Usage:"
30cdf0e10cSrcweir  echo "1. parameter: Path to the local root directory"
31cdf0e10cSrcweir  echo "All packages in local database will be removed!"
32cdf0e10cSrcweir  exit 2
33cdf0e10cSrcweirfi
34cdf0e10cSrcweir
35cdf0e10cSrcweirMY_ROOT=$1
36cdf0e10cSrcweir
37cdf0e10cSrcweircd `dirname $0`
38cdf0e10cSrcweirDIRECTORY=`pwd`
39cdf0e10cSrcweir
40cdf0e10cSrcweirGETUID_SO=/tmp/getuid.so.$$
41cdf0e10cSrcweirlinenum=???
42cdf0e10cSrcweirtail +$linenum `basename $0` > $GETUID_SO
43cdf0e10cSrcweir
44cdf0e10cSrcweirPKGLIST=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep -v core`
45cdf0e10cSrcweirCOREPKG=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core`
46cdf0e10cSrcweirCOREPKG01=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core01`
47cdf0e10cSrcweir
48cdf0e10cSrcweirecho "#############################################"
49cdf0e10cSrcweirecho "#     Deinstallation of Office packages     #"
50cdf0e10cSrcweirecho "#############################################"
51cdf0e10cSrcweirecho
52cdf0e10cSrcweirecho "Path to the root directory :  " $MY_ROOT
53cdf0e10cSrcweirecho
54cdf0e10cSrcweirecho "Packages to deinstall:"
55cdf0e10cSrcweirfor i in $PKGLIST $COREPKG; do
56cdf0e10cSrcweir  echo $i
57cdf0e10cSrcweirdone
58cdf0e10cSrcweir
59cdf0e10cSrcweirINSTALL_DIR=$MY_ROOT`pkginfo -R $MY_ROOT -r $COREPKG01`
60cdf0e10cSrcweir
61cdf0e10cSrcweir# Restore original bootstraprc
62cdf0e10cSrcweirmv -f $INSTALL_DIR/program/bootstraprc.orig $INSTALL_DIR/program/bootstraprc
63cdf0e10cSrcweir
64cdf0e10cSrcweirfor i in $PKGLIST $COREPKG; do
65cdf0e10cSrcweir  LD_PRELOAD=$GETUID_SO /usr/sbin/pkgrm -n -R $MY_ROOT $i
66cdf0e10cSrcweirdone
67cdf0e10cSrcweir
68cdf0e10cSrcweir# Removing old root directory, very dangerous!
69cdf0e10cSrcweir# rm -rf $MY_ROOT
70cdf0e10cSrcweir
71cdf0e10cSrcweir# removing library in temp directory
72cdf0e10cSrcweirrm -f $GETUID_SO
73cdf0e10cSrcweir
74cdf0e10cSrcweirecho
75cdf0e10cSrcweirecho "Deinstallation done..."
76cdf0e10cSrcweir
77cdf0e10cSrcweirexit 0
78