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