Benutzer:Andreas Plank/Wiki-Skripte
< Benutzer:Andreas Plank
Zur Navigation springen
Zur Suche springen
Version vom 11. Juli 2018, 19:34 Uhr von Andreas Plank (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „BASH Skript zum Herunterladen von Extensions in das Benutzerverzeichnis <code>~/tmp</code> und extrahieren in den Wiki-Ordner <code>$wikiExtPath</code> <syntax…“)
BASH Skript zum Herunterladen von Extensions in das Benutzerverzeichnis ~/tmp
und extrahieren in den Wiki-Ordner $wikiExtPath
#!/bin/bash
# What does it do? dowload and extract a standard Wiki extension
# requires: ~/tmp
wikiExtPath=/apps/mediawiki/www/extensions/
declare -A EXTURL # associative array
# EXTURL[NameOfExtension]=download-URL
# find the tar.gz URL e.g. at https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MassEditRegex
EXTURL[MassEditRegex]=https://extdist.wmflabs.org/dist/extensions/MassEditRegex-REL1_31-fcc91e5.tar.gz
EXTURL[MsUpload]=https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_31-2e2efd5.tar.gz
i_ext=1
for thisExt in "${!EXTURL[@]}";
do
# go to local tmp user directory
if ! [[ -d ~/tmp ]];then mkdir ~/tmp; echo "# Created user directory ~/tmp";fi
cd ~/tmp
echo "### Step $i_ext of ${#EXTURL[@]}"
echo "# Download $thisExt to `pwd`…"
wget --no-verbose "${EXTURL[$thisExt]}"
if [[ -d "${wikiExtPath}${thisExt}" ]];then
# timed backup e.g. MassEditRegex_backup201807112116
thisBackupPath="${wikiExtPath}${thisExt}_backup`date +%Y%m%d%H%M`"
echo "# Back up $thisExt to ${thisBackupPath} …"
mv "${wikiExtPath}${thisExt}" "${thisBackupPath}";
fi
echo "# Extract tar archive ${EXTURL[$thisExt]##*/} to ${wikiExtPath} …"
tar -xzf "${EXTURL[$thisExt]##*/}" -C "${wikiExtPath}"
i_ext=$(( i_ext + 1 ))
done