Benutzer:Andreas Plank/Wiki-Skripte
< Benutzer:Andreas Plank
Zur Navigation springen
Zur Suche springen
Version vom 12. Juli 2018, 10:37 Uhr von Andreas Plank (Diskussion | Beiträge) (→Extension herunterladen und extrahieren: +Hinweise)
Extension herunterladen und extrahieren
BASH Skript download_and_extract_wiki_extensions.sh
zum Herunterladen von Extensionen in das Benutzerverzeichnis ~/tmp
und extrahieren in den Wiki-Ordner $wikiExtPath
Hinweise:
- Extension:Translate & Co manuelle Installation über https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle
- Extension:SyntaxHighlight_GeSHi benötigt zusätzlich interne Installationen
- Extension:SemanticMediaWiki & Co über composer.local.json
#!/bin/bash
# description: What does it do? dowload and extract a standard Wiki extension
# EXTURL stores the extension name and the download URL you can find the tar.gz URL e.g. at
# https://www.mediawiki.org/wiki/Special:ExtensionDistributor/MassEditRegex
# https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=MassEditRegex&extdistversion=REL1_31
# 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[CategoryTree]=https://extdist.wmflabs.org/dist/extensions/CategoryTree-REL1_31-c24e5ed.tar.gz
# EXTURL[Cite]=https://extdist.wmflabs.org/dist/extensions/Cite-REL1_31-20e26df.tar.gz
EXTURL[CodeMirror]=https://extdist.wmflabs.org/dist/extensions/CodeMirror-REL1_31-a435d54.tar.gz
# EXTURL[ConfirmEdit]=https://extdist.wmflabs.org/dist/extensions/ConfirmEdit-REL1_31-b52469c.tar.gz
EXTURL[DismissableSiteNotice]=https://extdist.wmflabs.org/dist/extensions/DismissableSiteNotice-REL1_31-73a6b72.tar.gz
EXTURL[Echo]=https://extdist.wmflabs.org/dist/extensions/Echo-REL1_31-ed7f8f4.tar.gz
# EXTURL[Gadgets]=https://extdist.wmflabs.org/dist/extensions/Gadgets-REL1_31-bac29ae.tar.gz
# EXTURL[InputBox]=https://extdist.wmflabs.org/dist/extensions/InputBox-REL1_31-dfec261.tar.gz
EXTURL[MassEditRegex]=https://extdist.wmflabs.org/dist/extensions/MassEditRegex-REL1_31-fcc91e5.tar.gz
EXTURL[MsCalendar]=https://extdist.wmflabs.org/dist/extensions/MsCalendar-REL1_31-4cb0d01.tar.gz
# EXTURL[MsUpload]=https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_31-2e2efd5.tar.gz
EXTURL[Nuke]=https://extdist.wmflabs.org/dist/extensions/Nuke-REL1_31-c6ec842.tar.gz
EXTURL[Thanks]=https://extdist.wmflabs.org/dist/extensions/Thanks-REL1_31-a845a46.tar.gz
EXTURL[UserMerge]=https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_31-a641f0c.tar.gz
EXTURL[Variables]=https://extdist.wmflabs.org/dist/extensions/Variables-REL1_31-872663b.tar.gz
### Variables End
# get extensionList
extensionList=""
for thisExt in "${!EXTURL[@]}";
do
[[ -z ${extensionList// /} ]] && extensionList="$thisExt" || extensionList="$extensionList $thisExt"
# test if extension matches in URL
if [[ ${EXTURL[$thisExt]} != *${thisExt}* ]];then
echo -e "\033[0;31m# WARNING ${thisExt} does not match in ${EXTURL[$thisExt]}\033[0m"
fi
done
# prompt before starting
echo -e "\033[0;32m##########################\033[0m"
echo -e "\033[0;32m# Extract ${#EXTURL[@]} Extensions ...\033[0m"
echo -e "\033[0;32m# $extensionList\033[0m"
echo -e "\033[0;32m# ... to $wikiExtPath ?\033[0m"
echo -en "\033[0;32m# yes or no (default: no)\033[0m "
read yesno
if [[ -z ${yesno// /} ]];then yesno="no"; fi
case $yesno in
[yY]|[yY][eE][sS])
echo "# continue ..."
;;
[nN]|[nN][oO])
echo "### Stop";
exit 1
;;
*)
if [[ -z ${yesno// /} ]];then
echo -e "\033[0;32m### Stop\033[0m"
else
echo "### Wrong input „${yesno}“ (Stop)"
fi
exit 1
;;
esac
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
# last modification timed as backup date e.g. MassEditRegex_2017-09-22
modDate=$(stat -c %y "${wikiExtPath}${thisExt}")
modDate=${modDate%% *} # remove from 1st space to the end in date time: 2017-09-22 00:12:10.000000000 +0200
thisBackupPath="${wikiExtPath}${thisExt}_${modDate}"
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