#!/bin/bash #- # MediaWiki Plugin full dump/restore for FusionForge # # Copyright © 2013, 2015 # Thorsten “mirabilos” Glaser # Copyright (C) 2014 Inria (Sylvain Beucler) # All rights reserved. # # This file is part of FusionForge. FusionForge is free software; # you can redistribute it and/or modify it under the terms of the # GNU General Public License as published by the Free Software # Foundation; either version 2 of the Licence, or (at your option) # any later version. # # FusionForge is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with FusionForge; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Restores all pages and images from a file stored by mw-fulldump. # Passing not a file generated by mw-fulldump is Undefined Behaviour. # # Existing pages and files in the wiki will not be deleted; existing # pages with same names as those in the dump will be overwritten I guess. wikiprojectdir=$(forge_get_config projects_path mediawiki)/$1 if [[ $# != 2 || $1 = *[[:space:]]* || ! -s $2 ]]; then echo 'Syntax: mw-fullrestore tgtprojectname src.fulldump' 1>&2 exit 255 fi # check if project uses Wiki at all $(forge_get_config plugins_path)/mediawiki/bin/mw-wrapper.php "$1" \ showStats.php >/dev/null || exit $? set -x set -e rm -rf "$wikiprojectdir/fulldump" (cd "$wikiprojectdir" && tar xzf -) <"$2" cd "$wikiprojectdir/fulldump" $(forge_get_config plugins_path)/mediawiki/bin/mw-wrapper.php "$1" \ importImages.php mfi/ $(forge_get_config plugins_path)/mediawiki/bin/mw-wrapper.php "$1" \ importDump.php df.xml cd .. rm -rf fulldump chown -R www-data:www-data \ "$wikiprojectdir/images" $(forge_get_config plugins_path)/mediawiki/bin/mw-wrapper.php "$1" \ rebuildrecentchanges.php $(forge_get_config plugins_path)/mediawiki/bin/mw-wrapper.php "$1" update.php --quick exit 0