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
29REGISTERFILE=$PROGRAMDIR/register.dat
30UNOPKG=$PROGRAMDIR/unopkg
31
32help()
33{
34    echo
35    echo "Installation script for office extensions located in <office>/share/extension/install"
36    echo
37    echo "This installation script can be executed after successful installation of packages."
38    echo "Before uninstallation please execute the script \"deregister_extensions\" located next"
39    echo "to this script."
40    echo "Usage: $0"
41    echo "No parameter required."
42    echo
43}
44
45#
46# This script is only for root installations
47# (How about installations done with user privileges?)
48#
49
50# if [ $UID -ne 0 ]
51# then
52#     printf "\nThis script is for installation only wiht administrative rights only\n"
53#     help
54#     exit 2
55# fi
56
57#
58# Checking existence of unopkg in program directory
59#
60
61if [ ! -f "$UNOPKG" ]; then
62    echo "Error: File $UNOPKG does not exist"
63    exit 1
64fi
65
66if [ ! -x "$UNOPKG" ]; then
67    echo "Error: File $UNOPKG is not an executable file"
68    exit 1
69fi
70
71#
72# Collecting all files located in share/install/extensions
73#
74
75FILELIST=`find $EXTENSIONDIR -type f -name "*.oxt" -print`
76
77if [ -z "$FILELIST" ]
78then
79    printf "\n$0: No extensions found in $EXTENSIONDIR\n"
80    exit 2
81fi
82
83echo
84echo "Installing:"
85for i in $FILELIST; do
86    echo `basename $i`
87done
88echo
89
90for i in $FILELIST; do
91    COMMAND="$UNOPKG add --shared --suppress-license $i"
92    echo $COMMAND
93    $COMMAND
94done
95
96if [ -f $REGISTERFILE ]; then
97    rm $REGISTERFILE
98fi
99
100echo
101echo "Installation done ..."
102echo
103
104exit 0
105