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