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