3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # java-set-classpath - Utility to update the default
11 # CLASSPATH for LibreOffice
13 if test "z$1" = "z" ; then
14 echo "Update the default CLASSPATH for LibreOffice"
16 echo "Usage: $0 [dir|jar]..."
18 echo "The utility updates the LibreOffice system setting. It adds or removes"
19 echo "the given directories and jar-files to or from the default CLASSPATH"
20 echo "depending on if they are available on the system or not."
23 echo " dir - absolute path to a directory"
24 echo " jar - absolute path to a jar-file"
28 JVM_CONFIG_FILE
=@INSTALLDIR@
/program
/fundamentalrc
31 if test "z${path%%/*}" != "z" ; then
32 echo "Warning: the path "$path" is not absolute and will be ignored"
35 if test -e $path ; then
37 grep "URE_MORE_JAVA_CLASSPATH_URLS.*file:/*$path\([[:space:]].*\)\?$" $JVM_CONFIG_FILE >/dev
/null
&& continue
38 # it is not registered
39 TMP_FILE
=`mktemp /tmp/ooset-java-class.XXXXXXXXXX` ||
exit 1
40 sed -e "s|^\(.*URE_MORE_JAVA_CLASSPATH_URLS.*\)$|\1 file://$path|" $JVM_CONFIG_FILE >$TMP_FILE
41 mv -f $TMP_FILE $JVM_CONFIG_FILE
42 chmod 644 $JVM_CONFIG_FILE
44 # the file does not exist, remove it from the configuration
45 TMP_FILE
=`mktemp /tmp/ooset-java-class.XXXXXXXXXX` ||
exit 1;
46 sed -e "s|^\(.*URE_MORE_JAVA_CLASSPATH_URLS.*\)file:/*$path\([[:space:]].*\)\?$|\1\2|" \
47 -e "s/\(URE_MORE_JAVA_CLASSPATH_URLS=\)[[:space:]]\+/\1/" \
48 -e "/^.*URE_MORE_JAVA_CLASSPATH_URLS/s/[[:space:]]\+/ /g" \
49 -e "/^.*URE_MORE_JAVA_CLASSPATH_URLS/s/[[:space:]]*$//" $JVM_CONFIG_FILE >$TMP_FILE
50 mv -f $TMP_FILE $JVM_CONFIG_FILE
51 chmod 644 $JVM_CONFIG_FILE