diff --git a/Dockerfile b/Dockerfile index 1b0c577..2d55e1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,16 +85,21 @@ RUN set -x \ # override environment to run redmine with a context path "/redmine" && mv ${WORKDIR}/config/environment.ces.rb ${WORKDIR}/config/environment.rb \ - # install core plugins to a temporary location - # besure plugin name does not contain a minus or dots, - # because the minus separates the version from the package name - && mkdir -p /var/tmp/redmine/plugins \ + # install core plugins + && mkdir -p "${WORKDIR}/plugins" \ + # install cas plugin + && mkdir "${WORKDIR}/plugins/redmine_cas" \ && curl -sL \ https://github.com/cloudogu/redmine_cas/archive/${CAS_PLUGIN_VERSION}.tar.gz \ - -o /var/tmp/redmine/plugins/redmine_cas-${CAS_PLUGIN_VERSION}.tar.gz \ + | tar xfz - --strip-components=1 -C "${WORKDIR}/plugins/redmine_cas" \ + # install redmine_activerecord_session_store to be able to invalidate sessions after cas logout + && mkdir "${WORKDIR}/plugins/redmine_activerecord_session_store" \ && curl -sL \ https://github.com/pencil/redmine_activerecord_session_store/archive/v${ACTIVERECORD_SESSION_STORE_PLUGIN_VERSION}.tar.gz \ - -o /var/tmp/redmine/plugins/redmine_activerecord_session_store-${ACTIVERECORD_SESSION_STORE_PLUGIN_VERSION}.tar.gz \ + | tar xfz - --strip-components=1 -C "${WORKDIR}/plugins/redmine_activerecord_session_store" \ + + # install plugin gems + && cd ${WORKDIR}; RAILS_ENV="production" bundle install --without development test \ # cleanup && rm -rf /root/* /tmp/* $(gem env gemdir)/cache \ diff --git a/dogu.json b/dogu.json index 302f456..fc907ed 100644 --- a/dogu.json +++ b/dogu.json @@ -20,7 +20,7 @@ "Group": "1000" }, { "Name": "plugins", - "Path": "/usr/share/webapps/redmine/plugins", + "Path": "/var/tmp/redmine/plugins", "Owner": "1000", "Group": "1000" }, { @@ -37,6 +37,9 @@ "Port": 3000 }, "ExposedCommands": [{ + "Name": "pre-upgrade", + "Command": "/pre-upgrade.sh" + },{ "Name": "post-upgrade", "Command": "/post-upgrade.sh" }] diff --git a/resources/post-upgrade.sh b/resources/post-upgrade.sh index 379619b..ab0cb72 100755 --- a/resources/post-upgrade.sh +++ b/resources/post-upgrade.sh @@ -16,9 +16,6 @@ function exec_rake() { echo "executing update ${FROM_VERSION} to ${TO_VERSION}" -echo "install dependencies ..." -RAILS_ENV="production" REDMINE_LANG="en" bundle install - echo "migrate database ..." exec_rake db:migrate diff --git a/resources/pre-upgrade.sh b/resources/pre-upgrade.sh new file mode 100755 index 0000000..a646c9b --- /dev/null +++ b/resources/pre-upgrade.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# older installation of redmine exposed the core plugins to the +# plugin volume, these exposed plugin could be old and must be +# removed. + +set -o errexit +set -o nounset +set -o pipefail + +PLUGIN_DIRECTORY="${WORKDIR}/plugins" +CORE_PLUGINS="redmine_activerecord_session_store redmine_cas" + +for CP in ${CORE_PLUGINS}; do + CP_DIR="${PLUGIN_DIRECTORY}/${CP}" + if [ -d "${CP_DIR}" ]; then + echo "remove old installation of ${CP}" + rm -rf "${CP_DIR}" + fi +done \ No newline at end of file diff --git a/resources/startup.sh b/resources/startup.sh index 7c520f6..eb0ccbc 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -36,14 +36,20 @@ function exec_rake() { function install_plugins(){ echo "installing plugins" - for PLUGIN_PACKAGE in $(ls "${PLUGIN_STORE}"); do + + PLUGINS=$(ls "${PLUGIN_STORE}") + for PLUGIN_PACKAGE in ${PLUGINS}; do install_plugin "${PLUGIN_PACKAGE}" done - echo "install missing gems ..." - RAILS_ENV="${RAILS_ENV}" REDMINE_LANG="${REDMINE_LANG}" bundle install - echo "missing gems ... installed" + # install missing gems only if external plugins are going to install + if [ "x${PLUGINS}" != "x" ]; then + echo "install missing gems ..." + RAILS_ENV="${RAILS_ENV}" REDMINE_LANG="${REDMINE_LANG}" bundle install + echo "missing gems ... installed" + fi + # run migrations always, because core plugins need also a db migration echo "running plugin migrations..." exec_rake redmine:plugins:migrate echo "plugin migrations... done" @@ -51,18 +57,20 @@ function install_plugins(){ # installs or upgrades the given plugin function install_plugin(){ - PACKAGE="${1}" - NAME=$(echo "${PACKAGE}" | awk -F'-' '{print $1}') - VERSION=$(echo "${PACKAGE}" | awk -F'-' '{print $NF}' | sed -e 's/\.tar\.gz//g') - DIRECTORY="${PLUGIN_DIRECTORY}/${NAME}" - - echo "install plugin ${NAME} in version ${VERSION}" - if [ -d "${DIRECTORY}" ]; then - rm -rf "${DIRECTORY}" + NAME="${1}" + SOURCE="${PLUGIN_STORE}/${NAME}" + TARGET="${PLUGIN_DIRECTORY}/${NAME}" + + if [ ! -d "${SOURCE}" ]; then + exit 1 fi - mkdir -p "${DIRECTORY}" - tar xfz "${PLUGIN_STORE}/${PACKAGE}" --strip-components=1 -C "${DIRECTORY}" > /dev/null 2>&1 + echo "install plugin ${NAME}" + if [ -d "${TARGET}" ]; then + rm -rf "${TARGET}" + fi + + cp -rf "${SOURCE}" "${TARGET}" } # adjust redmine database.yml @@ -141,8 +149,7 @@ else sql "DELETE FROM users WHERE login='admin';" fi - -# install core plugins and manual installed plugins +# install manual installed plugins install_plugins # Create links