Benutzer:Andreas Plank/Wiki-Skripte
< Benutzer:Andreas Plank
Zur Navigation springen
Zur Suche springen
Version vom 12. Juli 2018, 12:18 Uhr von Andreas Plank (Diskussion | Beiträge) (→MediaWiki Language Extension Bundle herunterladen und extrahieren: +download_and_extract_MLEB_extensions.sh)
Extensionen 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, siehe
download_and_extract_MLEB_extensions.sh
- 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
MediaWiki Language Extension Bundle herunterladen und extrahieren
BASH Skript download_and_extract_MLEB_extensions.sh
zum Herunterladen von https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle in das Benutzerverzeichnis ~/tmp
und extrahieren in den Wiki-Ordner $wikiExtPath
Hinweise:
- MLEB enthält einen Ordner
./extensions
deshalb kann nicht das Skriptdownload_and_extract_wiki_extensions.sh
verwendet werden - BUG https://phabricator.wikimedia.org/T178895 muss eventuell nachgepflegt werden, damit Yandex funktioniert
#!/bin/bash
# download_and_extract_MLEB_extensions.sh
# Documentation: https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle
# MLEB extracts to ./extensions/Babel ./extensions/Translate etc.
# the dowload package is extracted to tempPath (home user directory ~/tmp)
### variables start
# modify according to your needs
mwLangExtBundlebUrl=https://translatewiki.net/mleb/MediaWikiLanguageExtensionBundle-2018.07.tar.bz2
labelOldMLEB="MLEB-2018.04"
wikiExtPath=/apps/mediawiki/www/extensions/
tempPath=~/tmp/
### variables end
# prompt before starting
echo -e "\033[0;32m##########################\033[0m"
echo -e "\033[0;32m# Download $mwLangExtBundlebUrl to ${tempPath} ...\033[0m"
echo -e "\033[0;32m# * back up old extensions Babel_$labelOldMLEB cldr_$labelOldMLEB Translate_$labelOldMLEB etc.\033[0m"
if [[ -d ${tempPath}extensions ]]; then
echo -e "\033[0;32m# * \033[0;31mremove ${tempPath}extensions\033[0;32m and extract MLEB to ${tempPath} \033[0m"
else
echo -e "\033[0;32m# * extract MLEB into $tempPath copy to $wikiExtPath ?\033[0m"
fi
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
cd "${tempPath}"
if [[ -d extensions ]]; then
echo "# remove extensions folder ...";
rm -R extensions;
fi
echo "# Download ${mwLangExtBundlebUrl} to ${tempPath} …"
wget --no-verbose "${mwLangExtBundlebUrl}"
echo "# Extract ${mwLangExtBundlebUrl##*/} …"
tar -xjf ${mwLangExtBundlebUrl##*/} -C "${tempPath}"
for thisMLEBextension in "${tempPath}/extensions/"*;do
if [[ -d "$wikiExtPath${thisMLEBextension##*/}" ]];then
echo "# Back up in $wikiExtPath: ${thisMLEBextension##*/} -> ${thisMLEBextension##*/}_${labelOldMLEB} ..."
mv "$wikiExtPath${thisMLEBextension##*/}" "$wikiExtPath${thisMLEBextension##*/}_${labelOldMLEB}"
fi
echo "# Copy ${thisMLEBextension##*/} to $wikiExtPath${thisMLEBextension##*/} ..."
cp --preserve "$thisMLEBextension" "$wikiExtPath${thisMLEBextension##*/}"
done