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