#!/bin/bash
#
#
#   OPEN-XCHANGE legal information
#
#   All intellectual property rights in the Software are protected by
#   international copyright laws.
#
#
#   In some countries OX, OX Open-Xchange, open xchange and OXtender
#   as well as the corresponding Logos OX Open-Xchange and OX are registered
#   trademarks of the OX Software GmbH group of companies.
#   The use of the Logos is not covered by the GNU General Public License.
#   Instead, you are allowed to use these Logos according to the terms and
#   conditions of the Creative Commons License, Version 2.5, Attribution,
#   Non-commercial, ShareAlike, and the interpretation of the term
#   Non-commercial applicable to the aforementioned license is published
#   on the web site http://www.open-xchange.com/EN/legal/index.html.
#
#   Please make sure that third-party modules and libraries are used
#   according to their respective licenses.
#
#   Any modifications to this package must retain all copyright notices
#   of the original copyright holder(s) for the original code used.
#
#   After any such modifications, the original and derivative code shall remain
#   under the copyright of the copyright holder(s) and/or original author(s)per
#   the Attribution and Assignment Agreement that can be located at
#   http://www.open-xchange.com/EN/developer/. The contributing author shall be
#   given Attribution for the derivative code and a license granting use.
#
#    Copyright (C) 2016-2020 OX Software GmbH
#    Mail: info@open-xchange.com
#
#
#    This program is free software; you can redistribute it and/or modify it
#    under the terms of the GNU General Public License, Version 2 as published
#    by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
#    for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc., 59
#    Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#

OXFUNCTIONS=/opt/open-xchange/lib/oxfunctions.sh
OXCONFIG=/opt/open-xchange/imageconverter/etc/ox-scriptconf.sh
OXPREFIX=@prefix@
OXBUNDLES=$OXPREFIX/bundles

test -f $OXFUNCTIONS || {
    echo "missing common shell functions file"
    exit 1
}

. $OXFUNCTIONS

test -f $OXCONFIG && . $OXCONFIG

ox_set_JAVA_BIN

test -z "$JAVA_OXCMD_OPTS" && JAVA_OXCMD_OPTS="-Xmx280M"

JAVA_OPTS="${JAVA_OXCMD_OPTS} \
-Djava.awt.headless=true \
-Dopenexchange.propdir=$PROPERTIESDIR"

CLASSPATH="-classpath /opt/open-xchange/bundles/org.glassfish.hk2.api-2.4.0-b10.jar:/opt/open-xchange/bundles/httpcore-osgi-4.4.13.jar:/opt/open-xchange/bundles/org.glassfish.hk2.locator-2.4.0-b10.jar:/opt/open-xchange/bundles/commons-cli-1.4.jar:/opt/open-xchange/bundles/org.glassfish.jersey.core.jersey-client-2.17.jar:/opt/open-xchange/bundles/commons-codec-1.14.jar:/opt/open-xchange/bundles/commons-csv-1.6.jar:/opt/open-xchange/bundles/com.openexchange.global/com.openexchange.global.jar:/opt/open-xchange/bundles/com.openexchange.global/lib/stringsearch-1.0.0.jar:/opt/open-xchange/bundles/com.openexchange.global/lib/stringsearch-2.jar:/opt/open-xchange/bundles/org.glassfish.hk2.utils-2.4.0-b10.jar:/opt/open-xchange/bundles/org.glassfish.hk2.external.javax.inject-2.4.0-b10.jar:/opt/open-xchange/bundles/commons-io-2.6.jar:/opt/open-xchange/bundles/javax.ws.rs-api-2.0.1.jar:/opt/open-xchange/bundles/org.glassfish.jersey.core.jersey-server-2.17.jar:/opt/open-xchange/bundles/jersey-entity-filtering-2.17.jar:/opt/open-xchange/bundles/org.glassfish.jersey.media.multipart_2.17.jar:/opt/open-xchange/bundles/org.glassfish.jersey.core.jersey-common-2.17.jar:/opt/open-xchange/bundles/org.json.jar:/opt/open-xchange/bundles/jersey-media-json-jackson-2.17.jar:/opt/open-xchange/bundles/com.openexchange.java.jar:/opt/open-xchange/bundles/javax.annotation-api-1.3.2.jar:/opt/open-xchange/bundles/org.glassfish.jersey.bundles.repackaged.jersey-guava-2.17.jar:/opt/open-xchange/bundles/org.glassfish.hk2.osgi-resource-locator-1.0.1.jar:/opt/open-xchange/bundles/org.glassfish.hk2.external.aopalliance-repackaged-2.4.0-b10.jar:/opt/open-xchange/bundles/org.eclipse.osgi_3.15.0.v20190830-1434.jar:/opt/open-xchange/bundles/javassist-3.18.1-GA.jar:/opt/open-xchange/bundles/jackson-annotations-2.11.0.jar:/opt/open-xchange/bundles/com.openexchange.annotation.jar:/opt/open-xchange/bundles/logback-core-1.2.3.jar:/opt/open-xchange/bundles/com.google.guava/lib/j2objc-annotations-1.3.jar:/opt/open-xchange/bundles/com.google.guava/lib/failureaccess-1.0.1.jar:/opt/open-xchange/bundles/com.google.guava/lib/checker-qual-2.10.0.jar:/opt/open-xchange/bundles/com.google.guava/lib/guava-30.0-jre.jar:/opt/open-xchange/bundles/com.google.guava/lib/error_prone_annotations-2.3.4.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/high-scale-lib-1.1.4.jar:/opt/open-xchange/bundles/com.openexchange.common/com.openexchange.common.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/nekohtml-1.9.22.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/jdo2-api-2.3-eb.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/rabin-hash-function-2.0.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/jboss-jms-api.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/mysql-connector-java-5.1.49.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/cache-api-1.1.0.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/trove-3.0.3.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/chardet-1.1.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/bucket4j-core-4.9.0.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/jts-1.13.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/cssparser-0.9.7.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/scribe-java-1.3.7.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/vinnie-2.0.2.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/jericho-html-3.4.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/jsoup-1.13.1.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/owasp-esapi-2.0.1.jar:/opt/open-xchange/bundles/com.openexchange.common/lib/gnu-rex.jar:/opt/open-xchange/bundles/logback-extensions-2.0.0.jar:/opt/open-xchange/bundles/log4j-over-slf4j-1.7.26.jar:/opt/open-xchange/bundles/slf4j-api-1.7.26.jar:/opt/open-xchange/bundles/javax.servlet-api-4.0.0.jar:/opt/open-xchange/bundles/logback-classic-1.2.3.jar:/opt/open-xchange/bundles/jcl-over-slf4j-1.7.26.jar:/opt/open-xchange/bundles/jackson-core-2.11.0.jar:/opt/open-xchange/bundles/org.eclipse.osgi.services_3.8.0.v20190206-2147.jar:/opt/open-xchange/bundles/javax.annotation.concurrent/lib/jsr305-3.0.2.jar:/opt/open-xchange/bundles/javax.annotation.concurrent/javax.annotation.concurrent.jar:/opt/open-xchange/bundles/javax.mail/lib/libidn-1.9.jar:/opt/open-xchange/bundles/javax.mail/lib/EmailAddress.jar:/opt/open-xchange/bundles/javax.mail/lib/emailaddress-rfc2822-2.2.0.jar:/opt/open-xchange/bundles/javax.mail/lib/jtnef-2.0.0.jar:/opt/open-xchange/bundles/javax.mail/lib/poi-3.17.jar:/opt/open-xchange/bundles/javax.mail/javax.mail.jar:/opt/open-xchange/bundles/com.openexchange.net.ssl.jar:/opt/open-xchange/bundles/com.openexchange.net/com.openexchange.net.jar:/opt/open-xchange/bundles/com.openexchange.net/lib/java-ipv6-0.17-SNAPSHOT.jar:/opt/open-xchange/bundles/com.openexchange.system.extension.jar:/opt/open-xchange/bundles/com.openexchange.net.ssl.config.jar:/opt/open-xchange/bundles/httpclient-osgi-4.5.13.jar:/opt/open-xchange/bundles/com.openexchange.net.ssl.management.jar:/opt/open-xchange/bundles/com.openexchange.osgi.jar:/opt/open-xchange/bundles/com.openexchange.logging.jar:/opt/open-xchange/bundles/com.openexchange.monitoring.jar:/opt/open-xchange/bundles/org.apache.commons.lang_2.6.0.v201404270220.jar:/opt/open-xchange/bundles/commons-validator-1.6.jar:/opt/open-xchange/bundles/com.openexchange.configread.jar:/opt/open-xchange/bundles/jul-to-slf4j-1.7.26.jar:/opt/open-xchange/bundles/org.apache.servicemix.bundles.kafka-clients-2.4.0_1.jar:/opt/open-xchange/bundles/com.openexchange.management.jar:/opt/open-xchange/bundles/gson-2.8.5.jar:/opt/open-xchange/bundles/juniversalchardet-1.0.3.jar:/opt/open-xchange/bundles/com.google.json/com.google.json.jar:/opt/open-xchange/bundles/com.google.json/lib/json-sanitizer-1.2.1.jar:/opt/open-xchange/bundles/com.openexchange.config.cascade.jar:/opt/open-xchange/bundles/org.yaml.snakeyaml/lib/snakeyaml-1.21.jar:/opt/open-xchange/bundles/org.eclipse.osgi.util_3.5.300.v20190708-1141.jar:/opt/open-xchange/bundles/commons-beanutils-1.9.3.jar:/opt/open-xchange/bundles/commons-collections-3.2.2.jar:/opt/open-xchange/bundles/commons-digester-2.1.jar:/opt/open-xchange/bundles/com.openexchange.database.jar:/opt/open-xchange/bundles/com.openexchange.database.migration.jar:/opt/open-xchange/bundles/liquibase.core.jar:/opt/open-xchange/bundles/com.openexchange.caching/lib/concurrent-1.3.4.jar:/opt/open-xchange/bundles/com.openexchange.caching/com.openexchange.caching.jar:/opt/open-xchange/bundles/com.openexchange.caching/lib/jcs-1.3-custom.jar:/opt/open-xchange/bundles/com.openexchange.threadpool.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/micrometer-registry-prometheus-1.5.1.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/simpleclient-0.8.1.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/simpleclient_servlet-0.8.1.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/com.openexchange.metrics.micrometer.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/micrometer-core-1.5.1.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/LatencyUtils-2.0.3.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/HdrHistogram-2.1.11.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/simpleclient_common-0.8.1.jar:/opt/open-xchange/bundles/com.openexchange.metrics.micrometer/lib/simpleclient_hotspot-0.8.1.jar:/opt/open-xchange/bundles/org.w3c.css.sac_1.3.1.v200903091627.jar:/opt/open-xchange/bundles/com.openexchange.xerces/lib/xercesImpl-2.12.0.jar:/opt/open-xchange/bundles/com.openexchange.xerces/lib/xml-apis-1.4.01.jar:/opt/open-xchange/bundles/com.openexchange.xerces/lib/serializer-2.7.2.jar:/opt/open-xchange/bundles/com.openexchange.xerces/lib/xml-resolver-1.2.jar:/opt/open-xchange/bundles/commons-net-3.6.jar:/opt/open-xchange/bundles/com.openexchange.caching.events.jar:/opt/open-xchange/bundles/failsafe-1.1.1.jar:/opt/open-xchange/bundles/com.openexchange.config.lean.jar:/opt/open-xchange/bundles/commons-collections4-4.3.jar:/opt/open-xchange/bundles/javax.validation.api-1.1.0.Final.jar:/opt/open-xchange/bundles/org.jvnet.mimepull_1.9.4.jar:/opt/open-xchange/bundles/jackson-databind-2.11.0.jar:/opt/open-xchange/bundles/jackson-jaxrs-base-2.11.0.jar:/opt/open-xchange/bundles/jackson-jaxrs-json-provider-2.11.0.jar:/opt/open-xchange/bundles/jackson-module-jaxb-annotations-2.11.0.jar:/opt/open-xchange/imageconverter/lib/com.openexchange.imageconverter.clt.jar"

umask 066
exec $JAVA_BIN $JAVA_OPTS $CLASSPATH com.openexchange.imageconverter.clt.ImageConverterAdmin $@