Benutzer:Andreas Plank/Wiki-Skripte: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
 
__INHALTSVERZEICHNIS__
 
__INHALTSVERZEICHNIS__
  
== Extension herunterladen und extrahieren ==
+
== Extensionen herunterladen und extrahieren ==
  
BASH Skript <code>download_and_extract_wiki_extensions.sh</code> zum Herunterladen von Extensionen in das Benutzerverzeichnis <code>~/tmp</code> und extrahieren in den Wiki-Ordner <code>$wikiExtPath</code>
+
{{Anker|download_and_extract_wiki_extensions.sh}}<!--
 +
-->BASH Skript <code>download_and_extract_wiki_extensions.sh</code> zum Herunterladen von Extensionen in das Benutzerverzeichnis <code>~/tmp</code> und extrahieren in den Wiki-Ordner <code>$wikiExtPath</code>
  
 
Hinweise:  
 
Hinweise:  
* [[mediawikiwiki:Extension:Translate|Extension:Translate]] & Co manuelle Installation über https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle
+
* [[mediawikiwiki:Extension:Translate|Extension:Translate]] & Co manuelle Installation über https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle, siehe [[#download_and_extract_MLEB_extensions.sh|<code>download_and_extract_MLEB_extensions.sh</code>]]
 
* [[mediawikiwiki:Extension:SyntaxHighlight_GeSHi|Extension:SyntaxHighlight_GeSHi]] benötigt zusätzlich interne Installationen
 
* [[mediawikiwiki:Extension:SyntaxHighlight_GeSHi|Extension:SyntaxHighlight_GeSHi]] benötigt zusätzlich interne Installationen
 
* [[mediawikiwiki:Extension:SemanticMediaWiki|Extension:SemanticMediaWiki]] & Co über composer.local.json
 
* [[mediawikiwiki:Extension:SemanticMediaWiki|Extension:SemanticMediaWiki]] & Co über composer.local.json
Zeile 98: Zeile 99:
 
   tar -xzf "${EXTURL[$thisExt]##*/}" -C "${wikiExtPath}"
 
   tar -xzf "${EXTURL[$thisExt]##*/}" -C "${wikiExtPath}"
 
   i_ext=$(( i_ext + 1 ))
 
   i_ext=$(( i_ext + 1 ))
 +
done
 +
</syntaxhighlight>
 +
 +
 +
== '''M'''ediaWiki '''L'''anguage '''E'''xtension '''B'''undle herunterladen und extrahieren ==
 +
 +
{{Anker|download_and_extract_MLEB_extensions.sh}}<!--
 +
-->BASH Skript <code>download_and_extract_MLEB_extensions.sh</code> zum Herunterladen von [https://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle https://www.mediawiki.org/wiki/'''M'''ediaWiki_'''L'''anguage_'''E'''xtension_'''B'''undle] in das Benutzerverzeichnis <code>~/tmp</code> und extrahieren in den Wiki-Ordner <code>$wikiExtPath</code>
 +
 +
Hinweise:
 +
* MLEB enthält einen Ordner <code>./extensions</code> deshalb kann nicht das Skript [[#download_and_extract_wiki_extensions.sh|<code>download_and_extract_wiki_extensions.sh</code>]] verwendet werden
 +
* BUG https://phabricator.wikimedia.org/T178895 muss eventuell nachgepflegt werden, damit Yandex funktioniert
 +
 +
<syntaxhighlight lang="bash">
 +
#!/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
 
done
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 12. Juli 2018, 12:18 Uhr

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:

#!/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:

#!/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