Benutzer:Andreas Plank/Wiki-Skripte: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Extension herunterladen und extrahieren: Start & End) |
|||
Zeile 6: | Zeile 6: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
− | # What does it do? dowload and extract a standard Wiki extension | + | # description: What does it do? dowload and extract a standard Wiki extension |
− | # requires: ~/tmp | + | # requires: ~/tmp |
+ | ### Variables Start | ||
wikiExtPath=/apps/mediawiki/www/extensions/ | wikiExtPath=/apps/mediawiki/www/extensions/ | ||
declare -A EXTURL # associative array | declare -A EXTURL # associative array | ||
− | |||
# find the tar.gz URL e.g. at https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MassEditRegex | # 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[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 | EXTURL[MsUpload]=https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_31-2e2efd5.tar.gz | ||
+ | # EXTURL[NameOfExtension]=download-URL | ||
+ | ### Variables End | ||
i_ext=1 | i_ext=1 |
Version vom 11. Juli 2018, 19:41 Uhr
Extension herunterladen und extrahieren
BASH Skript zum Herunterladen von Extensions in das Benutzerverzeichnis ~/tmp
und extrahieren in den Wiki-Ordner $wikiExtPath
#!/bin/bash
# description: What does it do? dowload and extract a standard Wiki extension
# requires: ~/tmp
### Variables Start
wikiExtPath=/apps/mediawiki/www/extensions/
declare -A EXTURL # associative array
# 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
# EXTURL[NameOfExtension]=download-URL
### Variables End
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