1#!/bin/bash 2 3# First parameter: Root path that will be removed 4# MY_ROOT=/export/home/is/root 5 6if [ $# -ne 1 -o -z "$1" ] 7then 8 echo "One parameter required" 9 echo "Usage:" 10 echo "1. parameter: Path to the local root directory" 11 echo "All packages in local database will be removed!" 12 exit 2 13fi 14 15MY_ROOT=$1 16 17cd `dirname $0` 18DIRECTORY=`pwd` 19 20GETUID_SO=/tmp/getuid.so.$$ 21linenum=??? 22tail +$linenum `basename $0` > $GETUID_SO 23 24PKGLIST=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep -v core` 25COREPKG=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core` 26COREPKG01=`pkginfo -R $MY_ROOT | cut -f 2 -d ' ' | grep core01` 27 28echo "#############################################" 29echo "# Deinstallation of Office packages #" 30echo "#############################################" 31echo 32echo "Path to the root directory : " $MY_ROOT 33echo 34echo "Packages to deinstall:" 35for i in $PKGLIST $COREPKG; do 36 echo $i 37done 38 39INSTALL_DIR=$MY_ROOT`pkginfo -R $MY_ROOT -r $COREPKG01` 40 41# Restore original bootstraprc 42mv -f $INSTALL_DIR/program/bootstraprc.orig $INSTALL_DIR/program/bootstraprc 43 44for i in $PKGLIST $COREPKG; do 45 LD_PRELOAD=$GETUID_SO /usr/sbin/pkgrm -n -R $MY_ROOT $i 46done 47 48# Removing old root directory, very dangerous! 49# rm -rf $MY_ROOT 50 51# removing library in temp directory 52rm -f $GETUID_SO 53 54echo 55echo "Deinstallation done..." 56 57exit 0 58