diff --git a/library/roles/exist-db/defaults/main.yml b/library/roles/exist-db/defaults/main.yml new file mode 100644 index 0000000..80e19f5 --- /dev/null +++ b/library/roles/exist-db/defaults/main.yml @@ -0,0 +1,32 @@ +--- +exist_db_major: 5 +exist_db_minor: 2 +exist_db_patch: 0 +exist_db_version: '{{ exist_db_major }}.{{ exist_db_minor }}.{{ exist_db_patch }}' +exist_db_distribution_dir: 'exist-distribution-{{ exist_db_version }}' +exist_db_distribution: 'https://bintray.com/existdb/releases/download_file?file_path={{ exist_db_distribution_dir }}-unix.tar.bz2' +exist_db_http_port: 8080 + +exist_db_home: '/srv/existdb' +exist_db_data_dir: '/srv/existdb/data' +exist_db_journal_dir: '/srv/existdb/data-journal' +exist_db_backup_dir: '/srv/existdb/data-backups' +exist_db_base_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}' +exist_db_logdir: '/var/log/exist-db' +#exist_db_conf_dir: '/srv/existdb/etc' +exist_db_conf_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/etc' + +# Always express it in 'm' (MegaBytes) +exist_db_min_java_heap: '512' +exist_db_max_java_heap: '{{ exist_db_min_java_heap }}' +# exist_db_max_java_heap / 3 +exist_db_cache_size: '170' +exist_db_file_encoding: 'UTF-8' +exist_db_java_opts: "-Xms{{ exist_db_min_java_heap }}m -Xmx{{ exist_db_max_java_heap }}m -server -Djava.awt.headless=true -Dfile.encoding={{ exist_db_file_encoding }}" + +exist_db_consistency_enabled: True +exist_db_check_cron: "0 0 0/3 * * ?" +exist_db_max_backups_enabled: 6 +exist_db_backups_enabled: True +exist_db_incremental_backups_enabled: "yes" +exist_db_backup_cron: "0 0 0/12 * * ?" diff --git a/library/roles/exist-db/handlers/main.yml b/library/roles/exist-db/handlers/main.yml new file mode 100644 index 0000000..5d26c16 --- /dev/null +++ b/library/roles/exist-db/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: Restart existdb + service: name=exist-db state=started enabled=yes diff --git a/library/roles/exist-db/meta/main.yml b/library/roles/exist-db/meta/main.yml new file mode 100644 index 0000000..8d32511 --- /dev/null +++ b/library/roles/exist-db/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - { role: '../../library/roles/nginx', when: nginx_enabled is defined and nginx_enabled } + - { role: '../../library/roles/openjdk' } diff --git a/library/roles/exist-db/tasks/main.yml b/library/roles/exist-db/tasks/main.yml new file mode 100644 index 0000000..871ade1 --- /dev/null +++ b/library/roles/exist-db/tasks/main.yml @@ -0,0 +1,81 @@ +--- +- name: Create the exist-db user and the directory tree + block: + - name: Create the exist-db user + user: name={{ exist_db_user }} home={{ exist_db_home }} comment="eXist-db Service Account" createhome=no shell=/usr/sbin/nologin system=yes + + - name: Create the exist-db base path + file: dest={{ item }} state=directory mode=0750 owner=root group={{ exist_db_group }} + with_items: + - '{{ exist_db_home }}' + - '{{ exist_db_home }}/distribution' + - '{{ exist_db_conf_dir }}' + + - name: Create the exist-db directory tree + file: dest={{ item }} state=directory mode=0750 owner={{ exist_db_user }} group={{ exist_db_group }} + with_items: + - '{{ exist_db_data_dir }}' + - '{{ exist_db_journal_dir }}' + - '{{ exist_db_backup_dir }}' + - '{{ exist_db_logdir }}' + + - name: Link the log and data directories from the exist distribution directory + file: dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/{{ item }} state=absent + with_items: + - 'data' + - 'logs' + + - name: Link the log directory into the exist distribution directory + file: src={{ exist_db_logdir }} dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/logs state=link + + - name: Link the data directory into the exist distribution directory + file: src={{ exist_db_data_dir }} dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/data state=link + + tags: [ 'exist-db', 'exist_db' ] + +- name: Download and unpack the eXist DB distribution + block: + - name: Download the eXist DB archive + get_url: url={{ exist_db_distribution }} dest=/srv/exist-distribution-{{ exist_db_version }}-unix.tar.bz2 + + - name: Unarchive the eXist DB distribution + unarchive: src=/srv/exist-distribution-{{ exist_db_version }}-unix.tar.bz2 dest={{ exist_db_home }}/distribution remote_src=yes owner=root group=root + args: + creates: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/lib' + + tags: [ 'exist-db', 'exist_db' ] + +- name: Configure the eXistDB service + block: + - name: Install the changes to the configuration files in the custom etc/ directory + template: src={{ item }}.j2 dest={{ exist_db_conf_dir }}/{{ item }} + with_items: + - 'conf.xml' + - 'log4j2.xml' + notify: Restart existdb + + - name: Install the startup scripts + template: src={{ item }}.j2 dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/bin/{{ item }} owner=root group=root mode=0755 + with_items: + - 'startup.sh' + - 'shutdown.sh' + - 'backup.sh' + - 'client.sh' + - 'export.sh' + + - name: Install the exist-db systemd unit + template: src=exist-db.service.j2 dest=/lib/systemd/system/exist-db.service owner=root group=root mode=0644 + register: existdb_unit_install + + - name: Reload the systemd configuration + systemd: daemon_reload=yes + when: existdb_unit_install is changed + + - name: Ensure that the eXistDB service is running and enabled + service: name=exist-db state=started enabled=yes + + tags: [ 'exist-db', 'exist_db', 'exist_db_conf' ] + + + + \ No newline at end of file diff --git a/library/roles/exist-db/templates/backup.sh.j2 b/library/roles/exist-db/templates/backup.sh.j2 new file mode 100755 index 0000000..f03dae4 --- /dev/null +++ b/library/roles/exist-db/templates/backup.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="backup" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/library/roles/exist-db/templates/client.sh.j2 b/library/roles/exist-db/templates/client.sh.j2 new file mode 100755 index 0000000..405ae02 --- /dev/null +++ b/library/roles/exist-db/templates/client.sh.j2 @@ -0,0 +1,85 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="client" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/library/roles/exist-db/templates/conf.xml.j2 b/library/roles/exist-db/templates/conf.xml.j2 new file mode 100644 index 0000000..d7897ce --- /dev/null +++ b/library/roles/exist-db/templates/conf.xml.j2 @@ -0,0 +1,1040 @@ +{% raw %} + + + + +{% endraw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} +{% if exist_db_consistency_enabled %} + + + + + + + +{% endif %} +{% raw %} + +{% endraw %} +{% if exist_db_consistency_enabled %} + + + + + + + +{% endif %} +{% raw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} \ No newline at end of file diff --git a/library/roles/exist-db/templates/exist-db.service.j2 b/library/roles/exist-db/templates/exist-db.service.j2 new file mode 100644 index 0000000..e908c74 --- /dev/null +++ b/library/roles/exist-db/templates/exist-db.service.j2 @@ -0,0 +1,20 @@ +[Unit] +Description=eXist-db {{ exist_db_version }} Server +Documentation=http://www.exist-db.org/exist/apps/doc/documentation +After=syslog.target network.target + +[Service] +#Type=forking +Type=simple +SyslogIdentifier=existdb +User={{ exist_db_user }} +Group={{ exist_db_group }} +ExecStart={{ exist_db_base_dir }}/bin/startup.sh +ExecStop={{ exist_db_base_dir }}/bin/shutdown.sh +Restart=on-failure +RestartSec=30s +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + diff --git a/library/roles/exist-db/templates/export.sh.j2 b/library/roles/exist-db/templates/export.sh.j2 new file mode 100755 index 0000000..90c1a20 --- /dev/null +++ b/library/roles/exist-db/templates/export.sh.j2 @@ -0,0 +1,85 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="export" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/library/roles/exist-db/templates/log4j2.xml.j2 b/library/roles/exist-db/templates/log4j2.xml.j2 new file mode 100644 index 0000000..96f708b --- /dev/null +++ b/library/roles/exist-db/templates/log4j2.xml.j2 @@ -0,0 +1,252 @@ + + + + {{ exist_db_logdir }} +{% raw %} + 10MB + 14 + %d{yyyyMMddHHmmss} + %d [%t] %-5p (%F [%M]:%L) - %m %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} diff --git a/library/roles/exist-db/templates/shutdown.sh.j2 b/library/roles/exist-db/templates/shutdown.sh.j2 new file mode 100755 index 0000000..87cbbb7 --- /dev/null +++ b/library/roles/exist-db/templates/shutdown.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS {{ exist_db_java_opts }} -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="shutdown" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/library/roles/exist-db/templates/startup.sh.j2 b/library/roles/exist-db/templates/startup.sh.j2 new file mode 100755 index 0000000..5cd0e3c --- /dev/null +++ b/library/roles/exist-db/templates/startup.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser 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. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS {{ exist_db_java_opts }} -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="startup" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/library/roles/exist-db/vars/main.yml b/library/roles/exist-db/vars/main.yml new file mode 100644 index 0000000..a8a31c9 --- /dev/null +++ b/library/roles/exist-db/vars/main.yml @@ -0,0 +1,3 @@ +--- +exist_db_user: existdb +exist_db_group: '{{ exist_db_user }}'