1#!/bin/sh
2# *************************************************************
3#
4#  Licensed to the Apache Software Foundation (ASF) under one
5#  or more contributor license agreements.  See the NOTICE file
6#  distributed with this work for additional information
7#  regarding copyright ownership.  The ASF licenses this file
8#  to you under the Apache License, Version 2.0 (the
9#  "License"); you may not use this file except in compliance
10#  with the License.  You may obtain a copy of the License at
11#
12#    http://www.apache.org/licenses/LICENSE-2.0
13#
14#  Unless required by applicable law or agreed to in writing,
15#  software distributed under the License is distributed on an
16#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17#  KIND, either express or implied.  See the License for the
18#  specific language governing permissions and limitations
19#  under the License.
20#
21# *************************************************************
22
23USAGE="Usage: $0"
24
25SCRIPTNAME=`basename "$0"`
26PROGRAMDIR=`dirname "$0"`
27OFFICEDIR="$PROGRAMDIR/.."
28EXTENSIONDIR=$OFFICEDIR/share/extension/install
29UNOPKG=$PROGRAMDIR/unopkg
30
31help()
32{
33    echo
34    echo "Uninstallation script for office extensions located in <office>/share/extension/install"
35    echo
36    echo "This uninstallation script can be executed after successful installation of packages."
37    echo "Please execute this script, before uninstallation of packages."
38    echo "Usage: $0"
39    echo "No parameter required."
40    echo
41}
42
43#
44# This script is only for root installations
45# (How about installations done with user privileges?)
46#
47
48# if [ $UID -ne 0 ]
49# then
50#     printf "\nThis script is for installation only wiht administrative rights only\n"
51#     help
52#     exit 2
53# fi
54
55#
56# Checking existence of unopkg in program directory
57#
58
59if [ ! -f "$UNOPKG" ]; then
60    echo "Error: File $UNOPKG does not exist"
61    exit 1
62fi
63
64if [ ! -x "$UNOPKG" ]; then
65    echo "Error: File $UNOPKG is not an executable file"
66    exit 1
67fi
68
69#
70# Collecting all files located in share/install/extensions
71#
72
73FILELIST=`find $EXTENSIONDIR -type f -name "*.oxt" -print`
74
75if [ -z "$FILELIST" ]
76then
77    printf "\n$0: No extensions found in $EXTENSIONDIR\n"
78    exit 2
79fi
80
81echo
82echo "Uninstalling:"
83for i in $FILELIST; do
84    echo `basename $i`
85done
86echo
87
88for i in $FILELIST; do
89    COMMAND="$UNOPKG remove --shared `basename $i`"
90    echo $COMMAND
91    $COMMAND
92done
93
94echo
95echo "Uninstallation done ..."
96echo
97
98exit 0
99