1*cdf0e10cSrcweir#!/bin/bash
2*cdf0e10cSrcweir
3*cdf0e10cSrcweirUSAGE="Usage: $0"
4*cdf0e10cSrcweir
5*cdf0e10cSrcweirSCRIPTNAME=`basename "$0"`
6*cdf0e10cSrcweirPROGRAMDIR=`dirname "$0"`
7*cdf0e10cSrcweirOFFICEDIR="$PROGRAMDIR/.."
8*cdf0e10cSrcweirEXTENSIONDIR=$OFFICEDIR/share/extension/install
9*cdf0e10cSrcweirUNOPKG=$PROGRAMDIR/unopkg
10*cdf0e10cSrcweir
11*cdf0e10cSrcweirhelp()
12*cdf0e10cSrcweir{
13*cdf0e10cSrcweir    echo
14*cdf0e10cSrcweir    echo "Uninstallation script for office extensions located in <office>/share/extension/install"
15*cdf0e10cSrcweir    echo
16*cdf0e10cSrcweir    echo "This uninstallation script can be executed after successful installation of packages."
17*cdf0e10cSrcweir    echo "Please execute this script, before uninstallation of packages."
18*cdf0e10cSrcweir    echo "Usage: $0"
19*cdf0e10cSrcweir    echo "No parameter required."
20*cdf0e10cSrcweir    echo
21*cdf0e10cSrcweir}
22*cdf0e10cSrcweir
23*cdf0e10cSrcweir#
24*cdf0e10cSrcweir# This script is only for root installations
25*cdf0e10cSrcweir# (How about installations done with user privileges?)
26*cdf0e10cSrcweir#
27*cdf0e10cSrcweir
28*cdf0e10cSrcweir# if [ $UID -ne 0 ]
29*cdf0e10cSrcweir# then
30*cdf0e10cSrcweir#     printf "\nThis script is for installation only wiht administrative rights only\n"
31*cdf0e10cSrcweir#     help
32*cdf0e10cSrcweir#     exit 2
33*cdf0e10cSrcweir# fi
34*cdf0e10cSrcweir
35*cdf0e10cSrcweir#
36*cdf0e10cSrcweir# Checking existence of unopkg in program directory
37*cdf0e10cSrcweir#
38*cdf0e10cSrcweir
39*cdf0e10cSrcweirif [ ! -f "$UNOPKG" ]; then
40*cdf0e10cSrcweir    echo "Error: File $UNOPKG does not exist"
41*cdf0e10cSrcweir    exit 1
42*cdf0e10cSrcweirfi
43*cdf0e10cSrcweir
44*cdf0e10cSrcweirif [ ! -x "$UNOPKG" ]; then
45*cdf0e10cSrcweir    echo "Error: File $UNOPKG is not an executable file"
46*cdf0e10cSrcweir    exit 1
47*cdf0e10cSrcweirfi
48*cdf0e10cSrcweir
49*cdf0e10cSrcweir#
50*cdf0e10cSrcweir# Collecting all files located in share/install/extensions
51*cdf0e10cSrcweir#
52*cdf0e10cSrcweir
53*cdf0e10cSrcweirFILELIST=`find $EXTENSIONDIR -type f -name "*.oxt" -print`
54*cdf0e10cSrcweir
55*cdf0e10cSrcweirif [ -z "$FILELIST" ]
56*cdf0e10cSrcweirthen
57*cdf0e10cSrcweir    printf "\n$0: No extensions found in $EXTENSIONDIR\n"
58*cdf0e10cSrcweir    exit 2
59*cdf0e10cSrcweirfi
60*cdf0e10cSrcweir
61*cdf0e10cSrcweirecho
62*cdf0e10cSrcweirecho "Uninstalling:"
63*cdf0e10cSrcweirfor i in $FILELIST; do
64*cdf0e10cSrcweir    echo `basename $i`
65*cdf0e10cSrcweirdone
66*cdf0e10cSrcweirecho
67*cdf0e10cSrcweir
68*cdf0e10cSrcweirfor i in $FILELIST; do
69*cdf0e10cSrcweir    COMMAND="$UNOPKG remove --shared `basename $i`"
70*cdf0e10cSrcweir    echo $COMMAND
71*cdf0e10cSrcweir    $COMMAND
72*cdf0e10cSrcweirdone
73*cdf0e10cSrcweir
74*cdf0e10cSrcweirecho
75*cdf0e10cSrcweirecho "Uninstallation done ..."
76*cdf0e10cSrcweirecho
77*cdf0e10cSrcweir
78*cdf0e10cSrcweirexit 0
79