#!/bin/bash # an attempt to automatize packaging DokuWiki for openSUSE set -x RELEASE='2015-08-10' # hey, that's my birthday :) NO_OF_COMP=5 NEWNAME=$(echo "$RELEASE" | tr '-' '.') WORKDIR="$HOME/openSUSE/home:werfl/dw-temp" WWWDIR="$WORKDIR/DokuWiki/srv/www" NEWCONFDIR='/etc/DokuWiki' OLDCONFDIR="$WWWDIR/DokuWiki/conf" mkdir -p "$WORKDIR/DokuWiki/etc/apache2/conf.d" mkdir -p "$WWWDIR" # assume the standard download location DLFROM='http://download.dokuwiki.org/src/dokuwiki' DLFILE="dokuwiki-stable.tgz" # and get the file wget -O "${WWWDIR}/DokuWiki.tgz" "${DLFROM}/${DLFILE}" # unpack it cd "$WWWDIR" || exit 17 tar -xzf "DokuWiki.tgz" rm "DokuWiki.tgz" # move it into the right place, create config dirs mv "dokuwiki-${RELEASE}" DokuWiki HTACCESSLIST=$(find "${WWWDIR}/DokuWiki" -name '\.htacc*') cd "$WORKDIR/DokuWiki/etc" || exit 18 mv "$OLDCONFDIR" "$WORKDIR/DokuWiki${NEWCONFDIR}" cd "$WWWDIR/DokuWiki" ln -s "../../..${NEWCONFDIR}" "conf" # remove executable flags find "$WWWDIR/DokuWiki" -type f -executable | xargs chmod -x chmod +x $WWWDIR/DokuWiki/bin/*php # write config for Apache 2.2 and 2.4 # delete .htaccess, move it into Apache's conf cd "$WORKDIR/DokuWiki/etc" || exit 15 cat > 'apache2/conf.d/DokuWiki.conf' < Options None AllowOverride All DirectoryIndex doku.php index.html index.htm # Apache 2.4 Require all granted # Apache 2.2 Order allow,deny Allow from all EOT for SUBDIR in $HTACCESSLIST; do RELDIR=${SUBDIR#${WORKDIR}/DokuWiki} RELDIR=${RELDIR%/.htacc*} echo "" >> "apache2/conf.d/DokuWiki.conf" cat "$SUBDIR" >> "apache2/conf.d/DokuWiki.conf" echo "" >> "apache2/conf.d/DokuWiki.conf" echo " " >> "apache2/conf.d/DokuWiki.conf" rm "$SUBDIR" done dos2unix -o 'apache2/conf.d/DokuWiki.conf.*' cd "$WORKDIR" || exit 19 tar --strip-components=$NO_OF_COMP -cf "DokuWiki-${NEWNAME}.tar" DokuWiki bzip2 "DokuWiki-${NEWNAME}.tar"