User:Neiltyson1fan/How RationalWiki can autoupdate after switching to secure version

From RationalWiki
Jump to: navigation, search

Rn RW uses a Mediawiki version that is massively outdated from a security perspective, which has been the case for many months. https://www.mediawiki.org/wiki/Version_lifecycle In a few months it will vote on upgrading it. Here's how to install it to autoupdate on 1.35, using scripts I made from my own wiki farms if they want to use this, commenting out or adding extensions/skins as necessary. The few custom RW extensions could be temporarily disabled by the server admin to facilitate the update.

The wiki would first need to be upgraded by the server admins to 28, 29, 30, 31, 32, 33, 34, as necessary, using baby steps keep the database sane during upgrade

Process for autoupdating on 1.35 LTS[edit]

Install via Git:

mkdir -p /var/www/wikis/

cd /var/www/wikis

Bash script to run to install:

#! /bin/bash
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki
mv mediawiki s
cd s
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-vendor
mv mediawiki-vendor vendor
cd skins
rm -rf *
git clone -b REL1_35 --single-branch https://github.com/wikimedia/Vector
git clone -b REL1_35 --single-branch https://github.com/jthingelstad/foreground
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-skins-MinervaNeue
mv mediawiki-skins-MinervaNeue MinervaNeue
cd ../extensions
rm -rf *
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-CSS
mv mediawiki-extensions-CSS CSS
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-CategoryTree
mv mediawiki-extensions-CategoryTree CategoryTree
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Cite
mv mediawiki-extensions-Cite Cite
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-CommonsMetadata
mv mediawiki-extensions-CommonsMetadata CommonsMetadata
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-ConfirmEdit
mv mediawiki-extensions-ConfirmEdit ConfirmEdit
git clone -b REL1_35 --single-branch https://github.com/jaydenkieran/mw-discord
mv mw-discord Discord
git clone https://gitlab.com/hydrawiki/extensions/EmbedVideo
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Gadgets
mv mediawiki-extensions-Gadgets Gadgets
git clone https://github.com/teran/mediawiki-GoogleRichCards
mv mediawiki-GoogleRichCards GoogleRichCards
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Interwiki
mv mediawiki-extensions-Interwiki Interwiki
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-HitCounters
mv mediawiki-extensions-HitCounters HitCounters
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-LocalisationUpdate
mv mediawiki-extensions-LocalisationUpdate LocalisationUpdate
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Lockdown
mv mediawiki-extensions-Lockdown Lockdown
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-MobileDetect
mv mediawiki-extensions-MobileDetect MobileDetect
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-MobileFrontend
mv mediawiki-extensions-MobileFrontend MobileFrontend
git clone https://github.com/edwardspec/mediawiki-moderation
mv mediawiki-moderation Moderation
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-MultimediaViewer
mv mediawiki-extensions-MultimediaViewer MultimediaViewer
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-PageImages
mv mediawiki-extensions-PageImages PageImages
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-ParserFunctions
mv mediawiki-extensions-ParserFunctions ParserFunctions
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-MsUpload
mv mediawiki-extensions-MsUpload MsUpload
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Popups
mv mediawiki-extensions-Popups Popups
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-ReplaceText
mv mediawiki-extensions-ReplaceText ReplaceText
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Scribunto
mv mediawiki-extensions-Scribunto Scribunto
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-SyntaxHighlight_GeSHi
mv mediawiki-extensions-SyntaxHighlight_GeSHi SyntaxHighlight_GeSHi
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-TextExtracts
mv mediawiki-extensions-TextExtracts TextExtracts
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-Theme
mv mediawiki-extensions-Theme Theme
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-TimedMediaHandler
mv mediawiki-extensions-TimedMediaHandler TimedMediaHandler
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-VisualEditor
mv mediawiki-extensions-VisualEditor VisualEditor
git clone -b REL1_35 --single-branch  https://github.com/wikimedia/mediawiki-extensions-WikiEditor
mv mediawiki-extensions-WikiEditor WikiEditor
git clone -b REL1_35 --single-branch  https://github.com/wikimedia/mediawiki-extensions-WikiSEO
mv mediawiki-extensions-WikiSEO WikiSEO
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-YouTube
mv mediawiki-extensions-YouTube YouTube
git clone -b REL1_35 --single-branch https://github.com/wikimedia/mediawiki-extensions-CheckUser
mv mediawiki-extensions-CheckUser CheckUser
git -C /var/www/wikis/s/extensions/VisualEditor/ submodule update --init

mkdir /var/wikibackups

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"