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