diff options
Diffstat (limited to 'debian/dokuwiki-templates-extra.postinst')
-rwxr-xr-x | debian/dokuwiki-templates-extra.postinst | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/debian/dokuwiki-templates-extra.postinst b/debian/dokuwiki-templates-extra.postinst new file mode 100755 index 0000000..491985c --- /dev/null +++ b/debian/dokuwiki-templates-extra.postinst @@ -0,0 +1,65 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +case "${1}" in + configure) + db_get dokuwiki-templates/templates + TEMPLATES="${RET:-none}" + + db_stop + + # Handling templates + DIRECTORIES="$(cd /usr/share/dokuwiki/templates-extra && ls -d */ | sed -e 's|/$||g')" + + case "${TEMPLATES}" in + all) + TEMPLATES="${DIRECTORIES}" + ;; + + none) + TEMPLATES="" + ;; + + *) + TEMPLATES="$(echo ${TEMPLATES} | sed -e 's|,| |g')" + ;; + esac + + # Disabling all templates + for TEMPLATE in ${DIRECTORIES} + do + if [ -L "/var/lib/dokuwiki/lib/tpl/${TEMPLATE}" ] + then + if [ "$(dirname $(readlink /var/lib/dokuwiki/lib/tpl/"${TEMPLATE}"))" = "/usr/share/dokuwiki/templates-extra" ] + then + rm -f "/var/lib/dokuwiki/lib/tpl/${TEMPLATE}" + fi + fi + done + + # Enabling selected templates + for TEMPLATE in ${TEMPLATES} + do + if [ -e "/usr/share/dokuwiki/templates-extra/${TEMPLATE}" ] + then + ln -s "/usr/share/dokuwiki/templates-extra/${TEMPLATE}" "/var/lib/dokuwiki/lib/tpl/${TEMPLATE}" + fi + done + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`${1}'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 |