hs.scripts/updates/dokuwiki.sh
2024-04-25 13:49:12 +02:00

75 lines
2.1 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
echo
echo "WARNING: not well tested, please check the script first"
echo "WARNING: make sure to adjust required configs and plugins WITHIN THE SCRIPT before running initially!"
echo "FIXME: rsync might be more elegant midterm..."
echo "waiting 5s."
echo
sleep 5
mkdir -p $HOME/tmp
cd $HOME/tmp
# we prepare the update here in order to
# properly locate the target directory below
wget -q "https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz"
echo "Download completed."
tar xzf dokuwiki-stable.tgz
echo "Extracting completed."
rm -v *tgz*
# ---------------------------------------------------------------------------
releasedir=`ls $HOME/tmp/`
domain=`ls $HOME/doms/`
# define files we need to keep
plugins="backlinks,hostsharing,testing"
configs="acl.auth.php,plugins.local.php,local.php,users.auth.php"
# ---------------------------------------------------------------------------
read -p "Our domain appears to be: [ $domain ]. Is this correct? (yY)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo
target="$HOME/doms/$domain/htdocs-ssl"
oldversion=`cat $target/VERSION`
olddir=`readlink $target`
echo "The link target will be [ $target ]."
echo "The old directory was [ $olddir ]"
read -p "Our release dir appears to be: [ $releasedir ] and we are coming from [ $oldversion ]. Is this correct? (yY)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "Moving [ $releasedir ] home..."
mv -v $HOME/tmp/$releasedir $HOME/
cd $HOME
echo "Replacing the link in [ $target ]"
rm -v $target
ln -sv $HOME/$releasedir $target
cp -v $olddir/conf/{$configs} $target/conf/
echo "[ ! ] only known plugins will be copied over."
echo "[ ! ] please compare and configure the script accordingly"
cp -rp $olddir/lib/plugins/{$plugins} $target/lib/plugins/
echo "Copied [ $plugins ] to target."
echo "Copying .htaccess"
cp -vp $olddir/.htaccess $target/
echo
echo "All done!"
echo "Check the changelog: https://www.dokuwiki.org/changes"
echo "Check extensions for updates."