date | june 2020 |
---|---|
vaguely tested with | raspbian (debian 10 buster) |
DokuWiki stable Greebo 2018-04-22 | |
target public | Experienced users with good Linux and webserver configuration knowledge |
When one installs DokuWiki with apt-get on a debianish system, files are scattered all over the system and it may be difficult to move your installation to another server.
For this reason, the following script will recreate a vanilla DokuWiki installation tree in /tmp/dokuwiki-std
. It does not modify your original files. Files are copied. It only deals with the main wiki (debian installs a DokuWiki farm), and it requires that you are able to use sudo.
It works by downloading the stable DokuWiki and unpacking it in /tmp/dokuwiki-std
and then copying your config, plugins, templates, and data.
For the data, you may choose to link your current data to the new directory, This uses 0 bytes, so it may be a good thing if your data are huge and you're running short of storage space. But this may bring its own lot of issues as Debian uses secure but unusual permissions. The script will ask you what you want.
It also needs rsync and curl. So, make sure you have those programs. If in doubt :
sudo apt-get install curl rsync sudo
When the script is done, the directory /tmp/dokuwiki-std
contains a classic DokuWiki that you can move to your new server. See How to move DokuWiki from one Server to another?
USE, OR BE UNABLE TO USE, AT YOUR OWN RISKS ! The file is released under the CeCILL 2.1 Free license • https://cecill.info/licences/Licence_CeCILL_V2.1-en.html • https://cecill.info/licences/Licence_CeCILL_V2.1-fr.html |
---|
Click on the name to download.
#! /bin/bash # encoding: utf-8 # vim: se ts=2 sw=2 et ai mouse=: # Ce fichier est la propriété exclusive de schplurtz le Déboulonné # Copyright © 2020 Schplurtz le Déboulonné # Fichier sour licence CeCILL 2.1 # https://cecill.info/licences/Licence_CeCILL_V2.1-en.html # https://cecill.info/licences/Licence_CeCILL_V2.1-fr.html # FRENCH | ENGLISH # ------------------------------------+-------------------------------------- # Ce logiciel est un programme | This software is a computer program # informatique servant à reconstituer | whose purpose is to recreate a # un dokuwiki standard à partir d'une | standard dokuwiki from a debian # installation debian. | installation. # | # Ce logiciel est régi par la licence | This software is governed by the # CeCILL soumise au droit français et | CeCILL license under French law and # respectant les principes de | abiding by the rules of # diffusion des logiciels libres. | distribution of free software. You # Vous pouvez utiliser, modifier | can use, modify and/ or # et/ou redistribuer ce programme | redistribute the software under the # sous les conditions de la licence | terms of the CeCILL license as # CeCILL telle que diffusée par le | circulated by CEA, CNRS and INRIA # CEA, le CNRS et l'INRIA sur le site | at the following URL # "http://www.cecill.info/". | "http://www.cecill.info/". # | # En contrepartie de l'accessibilité | As a counterpart to the access to # au code source et des droits de | the source code and rights to # copie, de modification et de | copy, modify and redistribute # redistribution accordés par cette | granted by the license, users are # licence, il n'est offert aux | provided only with a limited # utilisateurs qu'une garantie | warranty and the software's # limitée. Pour les mêmes raisons, | author, the holder of the economic # seule une responsabilité restreinte | rights, and the successive # pèse sur l'auteur du programme, le | licensors have only limited # titulaire des droits patrimoniaux | liability. # et les concédants successifs. | # | # A cet égard l'attention de | In this respect, the user's # l'utilisateur est attirée sur les | attention is drawn to the risks # risques associés au chargement, à | associated with loading, using, # l'utilisation, à la modification | modifying and/or developing or # et/ou au développement et à la | reproducing the software by the # reproduction du logiciel par | user in light of its specific # l'utilisateur étant donné sa | status of free software, that may # spécificité de logiciel libre, qui | mean that it is complicated to # peut le rendre complexe à manipuler | manipulate, and that also # et qui le réserve donc à des | therefore means that it is # développeurs et des professionnels | reserved for developers and # avertis possédant des | experienced professionals having # connaissances informatiques | in-depth computer knowledge. Users # approfondies. Les utilisateurs | are therefore encouraged to load # sont donc invités à charger et | and test the software's suitability # tester l'adéquation du logiciel à | as regards their requirements in # leurs besoins dans des conditions | conditions enabling the security of # permettant d'assurer la sécurité de | their systems and/or data to be # leurs systèmes et ou de leurs | ensured and, more generally, to # données et, plus généralement, à | use and operate it in the same # l'utiliser et l'exploiter dans les | conditions as regards security. # mêmes conditions de sécurité. | # | # Le fait que vous puissiez accéder à | The fact that you are presently # cet en-tête signifie que vous avez | reading this means that you have # pris connaissance de la licence | had knowledge of the CeCILL license # CeCILL, et que vous en avez accepté | and that you accept its terms. # les termes. | : ---------------------------------------------------------------------------- # stop on 1st error set -e # log everything to /tmp/dw-repack.log exec 3>&2 2>/tmp/dw-repack.log 4>&2 set -x # Where we are going to work and repack DW. WORKDIR=/tmp/dokuwiki-std # in case of error, tail the log file trap 'tail /tmp/dw-repack.log' ERR # just in case # sudo apt-get -y install curl rsync echo Erase and recreate an empty workdir and untar a stable DW. sudo rm -rf $WORKDIR mkdir $WORKDIR cd $WORKDIR curl https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz | tar zxf - --no-same-owner --xform 's,^[^/]*,.,' echo copy your config files to dokuwiki cd /etc/dokuwiki for f in * ; do test -r $WORKDIR/conf/$f && continue test -h $f && continue cp $f $WORKDIR/conf done echo special case for users.auth.acl and acl.auth.php sudo cp /var/lib/dokuwiki/acl/acl.auth.php \ /var/lib/dokuwiki/acl/users.auth.php \ $WORKDIR/conf sudo chown $USER: $WORKDIR/conf/{users.auth.php,acl.auth.php} sudo chmod 0644 $WORKDIR/conf/{users.auth.php,acl.auth.php} echo remove debian settings cd $WORKDIR/conf test -e local.protected.php && sed -i -e '/savedir/d' local.protected.php test -e local.php && sed -i -e '/savedir/d' local.php test -e local.protected.php && sed -i -e '/userewrite/d' local.protected.php test -e local.php && sed -i -e '/userewrite/d' local.php echo copy plugins and templates cd /var/lib/dokuwiki/lib/plugins for f in * ; do test -r $WORKDIR/lib/plugins/$f && continue cp -a $f $WORKDIR/lib/plugins done cd /var/lib/dokuwiki/lib/tpl for f in * ; do test -r $WORKDIR/lib/tpl/$f && continue cp -a $f $WORKDIR/lib/tpl done echo "Now the data." printf %s " +-------------------------------------------------------------------------+ | You can choose to copy your data or to link your data into the new DW. | | linking uses 0 bytes. So if your data are huge, you might want to use | | this option. But if you link your data, the file permissions won't be | | modified. As Debian uses a secure but unusual set of permissions, it | | may create some issues later. | | | | to make it short : | " printf '| Use «copy» if you have enough space in %-32s |' $WORKDIR printf '%s\n' " | Use «link» otherwise | +-------------------------------------------------------------------------+ " # AAAAaaaarrrrgghhh.... selects prints its options on stderr... : select option in copy link ps3=$PS3 PS3='Enter the number that corresponds to your choice ' set +x select option in copy link ; do { set -x test $option && break } 2>&4 done 2>&3 PS3=$ps3 echo purge default dokuwiki data rm -rf $WORKDIR/data mkdir $WORKDIR/data if test $option = copy; then echo copy data sudo rsync -a --exclude 'cache/*' /var/lib/dokuwiki/data/. $WORKDIR/data/. sudo chown -hR $USER: $WORKDIR/data/. find $WORKDIR/data/. -type d -print0 | xargs -0 chmod 0755 find $WORKDIR/data/. -type f -print0 | xargs -0 chmod 0644 else echo link data sudo cp -al /var/lib/dokuwiki/data/. $WORKDIR/data/. sudo rm -rf "$WORKDIR/data/cache/*" fi echo echo ====================================== echo job done. echo log in /tmp/dw-repack.log echo new DokuWiki directory tree is $WORKDIR echo you may now archive or xfer this directory. echo have a nice day.