User:Neiltyson1fan/How RationalWiki can autoupdate

From RationalWiki
Jump to navigation Jump to search

A strategy to autoupdate a 1.35 Mediawiki install

Process for autoupdating on 1.35 LTS[edit]

Bash script to run to update via Git (and cron):

#! /bin/bash
echo "BACKING UP DATABASE"

d=`date +%H%M%b%d%g`
echo $d

mysqldump -h "localhost" -u "redacted" -p"redacted" --single-transaction --default-character-set=binary redacted > /var/wikibackups/rationalwiki"$d".sql

cd /var/wikibackups && ls -tp | grep -v '/$' | tail -n +21 | xargs -d '\n' -r rm --

echo "DONE BACKING UP DATABASE"
echo "UPDATING MEDIAWIKI"
for f in /var/www/wikis/s \
        /var/www/wikis/s/vendor \
        /var/www/wikis/s/extensions/CSS \
        /var/www/wikis/s/extensions/CheckUser \
        /var/www/wikis/s/extensions/Cite \
        /var/www/wikis/s/extensions/CommonsMetadata \
        /var/www/wikis/s/extensions/ConfirmEdit \
        /var/www/wikis/s/extensions/Discord \
        /var/www/wikis/s/extensions/EmbedVideo \
        /var/www/wikis/s/extensions/Gadgets \
        /var/www/wikis/s/extensions/GoogleRichCards \
        /var/www/wikis/s/extensions/HitCounters \
        /var/www/wikis/s/extensions/Interwiki \
        /var/www/wikis/s/extensions/Lockdown \
        /var/www/wikis/s/extensions/MobileFrontend \
        /var/www/wikis/s/extensions/Moderation \
        /var/www/wikis/s/extensions/MultimediaViewer \
        /var/www/wikis/s/extensions/PageImages \
        /var/www/wikis/s/extensions/ParserFunctions \
        /var/www/wikis/s/extensions/Popups \
        /var/www/wikis/s/extensions/ReplaceText \
        /var/www/wikis/s/extensions/Scribunto \
        /var/www/wikis/s/extensions/SyntaxHighlight_GeSHi \
        /var/www/wikis/s/extensions/TextExtracts \
        /var/www/wikis/s/extensions/Theme \
        /var/www/wikis/s/extensions/TimedMediaHandler \
        /var/www/wikis/s/extensions/VisualEditor \
        /var/www/wikis/s/extensions/WikiEditor \
        /var/www/wikis/s/extensions/WikiSEO \
        /var/www/wikis/s/extensions/YouTube \
        /var/www/wikis/s/skins/Vector \
        /var/www/wikis/s/skins/foreground \

do
        s=$(sudo git -C $f show -s | grep -m1 commit | cut -c 8-48)
        echo "`date`"
        echo "$f $s"
        sudo git -C $f pull
        p=$(sudo git -C $f show -s | grep -m1 commit | cut -c 8-48)
        if [ $s != $p ]; then
                echo "previous commit: $s"
                echo "current commit: $p"
        fi
        echo ""
done
git -C /var/www/wikis/s/extensions/VisualEditor/ submodule update --init
echo "DONE UPDATING MEDIAWIKI"

echo "UPDATING DATABASES"

echo "rationalwiki english"
php /var/www/wikis/s/maintenance/update.php --conf /var/www/rationalwiki.com/LocalSettings.php --force --quick


echo "DONE UPDATING DATABASES"
echo "DONE WITH ALL UPDATING"