drop old-wiki restore

This commit is contained in:
Jörg Thalheim 2024-04-01 14:49:19 +02:00
parent b6ddf22141
commit 4c6a0f5d39

View File

@ -42,53 +42,9 @@ let
mv ${wikiDump}{.tmp,} mv ${wikiDump}{.tmp,}
''; '';
}; };
old-wiki-restore = pkgs.writeShellApplication {
name = "old-wiki-restore";
runtimeInputs = [
config.services.postgresql.package
pkgs.coreutils
pkgs.util-linux
mediawiki-maintenance
];
text = ''
if $# != 1; then
echo "Usage: $0 <wikidump.xml.gz>" >&2
exit 1
fi
dump=$1
tmpdir=$(mktemp -d)
cleanup() { rm -rf "$tmpdir"; }
cd "$tmpdir"
chown mediawiki:nginx "$tmpdir"
rm -rf /var/lib/mediawiki-uploads
install -d -m 755 -o mediawiki -g nginx /var/lib/mediawiki-uploads
systemctl stop phpfpm-mediawiki.service
runuser -u postgres -- dropdb mediawiki
systemctl restart postgresql
runuser -u postgres -- psql -c "ALTER DATABASE mediawiki OWNER TO mediawiki"
systemctl restart mediawiki-init.service
cat <<EOF | runuser -u mediawiki -- mediawiki-maintenance deleteBatch.php
Main_Page
MediaWiki:About
EOF
trap cleanup EXIT
cp "$dump" "$tmpdir/wikidump.xml.gz"
chown mediawiki:nginx "$tmpdir/wikidump.xml.gz"
chmod 644 "$tmpdir/wikidump.xml.gz"
runuser -u mediawiki -- mediawiki-maintenance importDump.php --uploads "$tmpdir/wikidump.xml.gz"
runuser -u mediawiki -- mediawiki-maintenance rebuildrecentchanges.php
systemctl start phpfpm-mediawiki.service
'';
};
in in
{ {
environment.systemPackages = [ environment.systemPackages = [ mediawiki-maintenance ];
mediawiki-maintenance
old-wiki-restore
];
systemd.services.wiki-backup = { systemd.services.wiki-backup = {
path = [ pkgs.postgresql ]; path = [ pkgs.postgresql ];