From bf5bf36e2f484601fd2ce91c326c5d30bad9af3d Mon Sep 17 00:00:00 2001 From: Andrei Poenaru Date: Wed, 14 Mar 2018 22:14:00 +0000 Subject: [PATCH] Minor fixes based on comments to PR #9. Changes included: * Obtain the current dokuwiki released from the DOKUWIKI_VERSION environment variable set in the Dockerfile. * Only unpack the bundled dokuwiki release if we actually need to copy over new files. * Clean up the temporary copy of dokuwiki when we are done copying files from it. * Use `exec` to run the http server at the end of the startup script. * Document the `donwgrade` and `overwrite` comamnds. --- Dockerfile | 2 +- README.md | 10 ++++++++++ docker-startup.sh | 23 ++++++++++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 990eb36..41ae876 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ FROM ubuntu:16.04 MAINTAINER Miroslav Prasil # Set the version you want of Twiki -ARG DOKUWIKI_VERSION=2017-02-19e +ENV DOKUWIKI_VERSION=2017-02-19e ARG DOKUWIKI_CSUM=09bf175f28d6e7ff2c2e3be60be8c65f # Update & install packages & cleanup afterwards diff --git a/README.md b/README.md index e7261d9..f8845f1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ afterwards you can remove data container if you want Just stop the old container and run the new one with the same `-v` mapping. Since the data is on your file system, you do not need to do anything special to preserve it between containers. +#### Handling changes in bundled files inside volumes #### + +If you mount a volume that has previously been used with a newer version of DokuWiki than that installed in the current contaier, the newer files will _not_ be overwritten by those bundled with the current (older) version of DokuWiki. If you want to force a downgrade (at your own risk!), run the container with the `downgrade` command: + + docker run ... mprasil/dokuwiki donwgrade + +Additionally, if you make any changes to the files bundled with DokuWiki that are located in your volumes, these can be restored to the original version using the `overwrite` command: + + docker run ... mprasil/dokuwiki overwrite + Optimizing your wiki -------------------- diff --git a/docker-startup.sh b/docker-startup.sh index bf30f30..0b5a863 100755 --- a/docker-startup.sh +++ b/docker-startup.sh @@ -10,19 +10,15 @@ set -o pipefail # or fully populate these folders if this is the first run. dokudir=/dokuwiki +tmpdir=/tmp/dokuwiki verfile=.last-version +containerver="$(date -f <(echo "$DOKUWIKI_VERSION" | tr -d '[:alpha:]') +%s)" if [ ! -d "$dokudir" ]; then echo "DokuWiki does not appear to be installed correctly at: $dokudir." >&2 exit 1 fi -# Unpack a temporary copy -tmpdir=/tmp/dokuwiki -mkdir "$tmpdir" -tar -zxf /dokuwiki.tgz -C "$tmpdir" --strip-components 1 -containerver="$(date -f <(awk '{print $1}' "$tmpdir/VERSION" | tr -d '[:alpha:]') +%s)" - # Check for downgrade/overwrite parameters if [ "$1" = 'downgrade' ]; then downgrade=1; else downgrade=0; fi if [ "$1" = 'overwrite' ]; then overwrite=1; else overwrite=0; fi @@ -40,7 +36,13 @@ if [ "$1" = 'run' ] || [ "$1" = 'downgrade' ] || [ "$1" = 'overwrite' ]; then # Do nothing for equal versions continue elif [ "$volumever" -lt "$containerver" ] || [ "$downgrade" -eq 1 ] || [ "$overwrite" -eq 1 ]; then - # Update if the container version is newer than the volume version + # First, unpack a temporary copy of the current DokuWiki version + if [ ! -d "$tmpdir" ]; then + mkdir "$tmpdir" + tar -zxf /dokuwiki.tgz -C "$tmpdir" --strip-components 1 + fi + + # Then, update if the container version is newer than the volume version # Or if overridden using `downgrade` echo "Migrating $d..." cp -r "$tmpdir/$d/"* "$dokudir/$d/" @@ -50,17 +52,20 @@ if [ "$1" = 'run' ] || [ "$1" = 'downgrade' ] || [ "$1" = 'overwrite' ]; then cat >&2 <