1 cdf0e10cSrcweir#!/sbin/sh 2 b31e36b3SAndrew Rist# ************************************************************* 3 b31e36b3SAndrew Rist# 4 b31e36b3SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 5 b31e36b3SAndrew Rist# or more contributor license agreements. See the NOTICE file 6 b31e36b3SAndrew Rist# distributed with this work for additional information 7 b31e36b3SAndrew Rist# regarding copyright ownership. The ASF licenses this file 8 b31e36b3SAndrew Rist# to you under the Apache License, Version 2.0 (the 9 b31e36b3SAndrew Rist# "License"); you may not use this file except in compliance 10 b31e36b3SAndrew Rist# with the License. You may obtain a copy of the License at 11 b31e36b3SAndrew Rist# 12 b31e36b3SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 13 b31e36b3SAndrew Rist# 14 b31e36b3SAndrew Rist# Unless required by applicable law or agreed to in writing, 15 b31e36b3SAndrew Rist# software distributed under the License is distributed on an 16 b31e36b3SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 b31e36b3SAndrew Rist# KIND, either express or implied. See the License for the 18 b31e36b3SAndrew Rist# specific language governing permissions and limitations 19 b31e36b3SAndrew Rist# under the License. 20 b31e36b3SAndrew Rist# 21 b31e36b3SAndrew Rist# ************************************************************* 22 cdf0e10cSrcweir 23 cdf0e10cSrcweir. /lib/svc/share/smf_include.sh 24 cdf0e10cSrcweir 25 cdf0e10cSrcweir#The start method is used for installing and updating the 26 cdf0e10cSrcweir#extensions. The service keeps a list 27 cdf0e10cSrcweir#(share/extensions/install/installed) of the extensions which were 28 cdf0e10cSrcweir#already installed. During installation, the bundled extensions are 29 cdf0e10cSrcweir#copied to the install folder (share/extensions/install). Finally this 30 cdf0e10cSrcweir#service, which is part of the office installation package, will be 31 cdf0e10cSrcweir#started and the start "method" of this script is called. Then all 32 cdf0e10cSrcweir#extensions in the "install" folder are checked if they are already 33 cdf0e10cSrcweir#installed by reading the list "installed". Because the list is empty 34 cdf0e10cSrcweir#at this time, all the extensions will be installed. 35 cdf0e10cSrcweir# 36 cdf0e10cSrcweir#If this service is restarted then the script checks if there is an 37 cdf0e10cSrcweir#extensions which is not yet installed, that is there is no entry for 38 cdf0e10cSrcweir#it in the 'installed' file. Only if this is the case then that 39 cdf0e10cSrcweir#extensions will be installed and its path is added to 'installed'. 40 cdf0e10cSrcweir# 41 cdf0e10cSrcweir#In case of an update, new versions of existing extensions and 42 cdf0e10cSrcweir#completely new extensions may be copied to the 'install' folder. Also 43 cdf0e10cSrcweir#a new 'installed' file will be copied which replaces the existing 44 cdf0e10cSrcweir#file. The new 'installed' file does not contain any entries of 45 cdf0e10cSrcweir#installed extensions. Therefore the next time when the start method is 46 cdf0e10cSrcweir#run all extensions contained in share/extensions/install will be 47 cdf0e10cSrcweir#installed. 48 cdf0e10cSrcweir 49 cdf0e10cSrcweir#Create the folder which contains the temporary user installation 50 cdf0e10cSrcweirINSTDIR=`/usr/bin/mktemp -d "/tmp/userinstall.XXXXXX"` 51 cdf0e10cSrcweir 52 599cc5b4SOliver-Rainer WittmannOOO_BASE_DIR="/opt/openoffice/basis${OOOBASEVERSION}" 53 cdf0e10cSrcweir 54 cdf0e10cSrcweircase "$1" in 55 cdf0e10cSrcweir'start') 56 599cc5b4SOliver-Rainer Wittmann EXTENSIONDIR=/opt/openoffice${OOOBRANDPACKAGEVERSION}/share/extension/install 57 cdf0e10cSrcweir for FILE in $EXTENSIONDIR/*.oxt 58 cdf0e10cSrcweir do 59 cdf0e10cSrcweir #We check if the file exist, because if there is no extension 60 cdf0e10cSrcweir #then $FILE will contain "<..>/*.oxt" 61 cdf0e10cSrcweir if [ -f "$FILE" ]; then 62 cdf0e10cSrcweir #Determine if this extension is already installed. We do 63 cdf0e10cSrcweir #that by checking the file "installed" which contains a 64 cdf0e10cSrcweir #list of all installed extensions including the full path 65 cdf0e10cSrcweir EXTENSIONFILE=`basename $FILE` 66 cdf0e10cSrcweir INSTALLED=`sed -n "/$EXTENSIONFILE/p" $EXTENSIONDIR/installed` 67 cdf0e10cSrcweir 68 cdf0e10cSrcweir if [ -z "$INSTALLED" ]; then 69 cdf0e10cSrcweir #We have not found the name of the extension in the 70 cdf0e10cSrcweir #list. That is, it has not been installed (with unopkg) yet. 71 cdf0e10cSrcweir #Therefore we do it now. 72 cdf0e10cSrcweir echo installing $FILE 73 599cc5b4SOliver-Rainer Wittmann /opt/openoffice${OOOBRANDPACKAGEVERSION}/program/unopkg add --shared --bundled "$FILE" '-env:UserInstallation=file://$INSTDIR' '-env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml' '-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1' 74 cdf0e10cSrcweir #Let us remember that this extensions has been installed 75 cdf0e10cSrcweir #by adding the path name of the extension to the file 76 cdf0e10cSrcweir #installed 77 cdf0e10cSrcweir echo $FILE >> $EXTENSIONDIR/installed 78 cdf0e10cSrcweir fi 79 cdf0e10cSrcweir fi 80 cdf0e10cSrcweir done 81 cdf0e10cSrcweir 82 cdf0e10cSrcweir #Now check for extensions which need to be uninstalled 83 cdf0e10cSrcweir #(unopkg). This is the case if the list of extensions in the file 84 cdf0e10cSrcweir #installed contains the name of an extension which does not exist 85 *fb0b81f5Smseidel #in the folder <..>/share/extension/install. 86 cdf0e10cSrcweir# LINE="" 87 cdf0e10cSrcweir# NEWCONTENT="" 88 cdf0e10cSrcweir# REMOVED="" 89 cdf0e10cSrcweir# LIST=`cat $EXTENSIONDIR/installed` 90 cdf0e10cSrcweir# #remove blank lines 91 cdf0e10cSrcweir# LIST=`echo "$LIST" | sed '/^[:blank:]*$/d'` 92 cdf0e10cSrcweir 93 cdf0e10cSrcweir# echo "$LIST" | while [ 1 ] 94 cdf0e10cSrcweir# do 95 cdf0e10cSrcweir# read LINE || break 96 cdf0e10cSrcweir# if [ ! -f "$LINE" ]; then 97 cdf0e10cSrcweir# #The extension file has been removed from 98 cdf0e10cSrcweir# #share/extension/install. Now we remove the installed 99 cdf0e10cSrcweir# #extension 100 cdf0e10cSrcweir# echo removing `basename $LINE` 101 599cc5b4SOliver-Rainer Wittmann# /opt/openoffice${OOOBRANDPACKAGEVERSION}/program/unopkg remove --shared --bundled "`basename $LINE`" '-env:UserInstallation=file://$INSTDIR' '-env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml' '-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1' 102 cdf0e10cSrcweir# REMOVED=1 103 cdf0e10cSrcweir# else 104 cdf0e10cSrcweir# NEWCONTENT+=$LINE 105 cdf0e10cSrcweir# NEWCONTENT+="\n" 106 cdf0e10cSrcweir# fi 107 cdf0e10cSrcweir# done 108 cdf0e10cSrcweir 109 cdf0e10cSrcweir# #Write the new list to the file "installed". It now has all names 110 86e1cf34SPedro Giffuni# #remove which referred to previously removed extensions (removed 111 cdf0e10cSrcweir# #from .../share/extension/install) 112 cdf0e10cSrcweir# if [ "$REMOVED" ]; then 113 cdf0e10cSrcweir# #remove the last empty line 114 cdf0e10cSrcweir# NEWCONTENT=`echo "$NEWCONTENT" | sed '/^[:space:]*$/d'` 115 cdf0e10cSrcweir# echo "$NEWCONTENT" > $EXTENSIONDIR/installed 116 cdf0e10cSrcweir# fi 117 cdf0e10cSrcweir 118 cdf0e10cSrcweir ;; 119 cdf0e10cSrcweir 'stop') 120 cdf0e10cSrcweir echo "#### stop ####" 121 cdf0e10cSrcweir ;; 122 cdf0e10cSrcweir *) 123 cdf0e10cSrcweir echo "Usage: $0 { start | stop }" 124 cdf0e10cSrcweir exit 1 125 cdf0e10cSrcweir ;; 126 cdf0e10cSrcweiresac 127 cdf0e10cSrcweir 128 cdf0e10cSrcweirexit $SMF_EXIT_OK 129