summaryrefslogtreecommitdiff
path: root/setup_native/source/opensolaris/bundledextensions/svc-ooo_bundled_extensions
blob: 696277011133450a66d9335f24859c58fb71b034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/sbin/sh

. /lib/svc/share/smf_include.sh

#The start method is used for installing and updating the
#extensions. The service keeps a list
#(share/extensions/install/installed) of the extensions which were
#already installed. During installation, the bundled extensions are
#copied to the install folder (share/extensions/install). Finally this
#service, which is part of the office installation package, will be
#started and the start "method" of this script is called. Then all
#extensions in the "install" folder are checked if they are already
#installed by reading the list "installed". Because the list is empty
#at this time, all the extensions will be installed.
#
#If this service is restarted then the script checks if there is an
#extensions which is not yet installed, that is there is no entry for
#it in the 'installed' file. Only if this is the case then that
#extensions will be installed and its path is added to 'installed'.
#
#In case of an update, new versions of existing extensions and
#completely new extensions may be copied to the 'install' folder. Also
#a new 'installed' file will be copied which replaces the existing
#file. The new 'installed' file does not contain any entries of
#installed extensions. Therefore the next time when the start method is
#run all extensions contained in share/extensions/install will be
#installed.

#Create the folder which contains the temporary user installation
INSTDIR=`/usr/bin/mktemp -d "/tmp/userinstall.XXXXXX"`

OOO_BASE_DIR="/opt/openoffice.org/basis${OOOBASEVERSION}"

case "$1" in
'start')
    EXTENSIONDIR=/opt/openoffice.org${OOOBRANDPACKAGEVERSION}/share/extension/install
    for FILE in $EXTENSIONDIR/*.oxt
    do
	#We check if the file exist, because if there is no extension
	#then $FILE will contain "<..>/*.oxt"
	if [ -f "$FILE" ]; then
            #Determine if this extension is already installed. We do
	    #that by checking the file "installed" which contains a
	    #list of all installed extensions including the full path
	    EXTENSIONFILE=`basename $FILE`
	    INSTALLED=`sed -n "/$EXTENSIONFILE/p" $EXTENSIONDIR/installed`
	    
	    if [ -z "$INSTALLED" ]; then
	        #We have not found the name of the extension in the
		#list. That is, it has not been installed (with unopkg) yet.
		#Therefore we do it now.
		echo installing $FILE
		/opt/openoffice.org${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'
		#Let us remember that this extensions has been installed
		#by adding the path name of the extension to the file 
		#installed
		echo $FILE >> $EXTENSIONDIR/installed
	    fi
	fi
    done
    
    #Now check for extensions which need to be uninstalled
    #(unopkg). This is the case if the list of extensions in the file
    #installed contains the name of an extension which does not exist
    #in the the folder <..>/share/extension/install.
#     LINE=""
#     NEWCONTENT=""
#     REMOVED=""
#     LIST=`cat $EXTENSIONDIR/installed`
#     #remove blank lines
#     LIST=`echo "$LIST" | sed '/^[:blank:]*$/d'`
 
#     echo "$LIST" |  while [ 1 ]
#     do
# 	read LINE || break
# 	if [ ! -f "$LINE" ]; then
# 	    #The extension file has been removed from
# 	    #share/extension/install. Now we remove the installed
# 	    #extension
# 	    echo removing `basename $LINE`
# 	    /opt/openoffice.org${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'
# 	    REMOVED=1
# 	else
# 	    NEWCONTENT+=$LINE 
# 	    NEWCONTENT+="\n"	    
# 	fi
#     done 

#     #Write the new list to the file "installed". It now has all names
#     #remove which refered to previously removed extensions (removed
#     #from .../share/extension/install)
#     if  [ "$REMOVED" ]; then
# 	#remove the last empty line
# 	NEWCONTENT=`echo "$NEWCONTENT" | sed '/^[:space:]*$/d'`
# 	echo "$NEWCONTENT" > $EXTENSIONDIR/installed
#     fi
    
    ;;
    'stop')
	echo "#### stop ####"
	;;
    *)
	echo "Usage: $0 { start | stop }"
	exit 1
	;;
esac

exit $SMF_EXIT_OK