From e302032bfd7b7d3503b167f0dc21829590043fcc Mon Sep 17 00:00:00 2001 From: stuzer05 Date: Mon, 22 Apr 2024 15:30:51 +0300 Subject: [PATCH] Add automatic mediawiki extension download url parser --- Dockerfile | 22 ++++++++++---------- build/scripts/mediawiki-ext-search.sh | 30 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 11 deletions(-) create mode 100755 build/scripts/mediawiki-ext-search.sh diff --git a/Dockerfile b/Dockerfile index e802f9c..f283d1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,18 +11,18 @@ RUN apt update && apt install --yes wget gpg \ # download extensions RUN apt install wget \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/AdvancedSearch-REL1_41-5161aa3.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/CirrusSearch-REL1_41-cf90f2e.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/DynamicSidebar-REL1_41-1414e53.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/Elastica-REL1_41-24f94b8.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_41-7e9d1d4.tar.gz \ - #&& wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/Mpdf-REL1_41-4bad605.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/Popups-REL1_41-f85dc5d.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/TimedMediaHandler-REL1_41-6851071.tar.gz \ - && wget -P /tmp/mediawiki_extensions https://extdist.wmflabs.org/dist/extensions/UserFunctions-REL1_41-4dee0d1.tar.gz + && /tmp/scripts/mediawiki-ext-search.sh AdvancedSearch REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh CirrusSearch REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh DynamicSidebar REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh Elastica REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh MobileFrontend REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh Mpdf REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh Popups REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh TimedMediaHandler REL1_41 | xargs wget -P /tmp/mediawiki_extensions \ + && /tmp/scripts/mediawiki-ext-search.sh UserFunctions REL1_41 | xargs wget -P /tmp/mediawiki_extensions -RUN find /tmp/mediawiki_extensions -name "*.tar.gz" -exec sh -c 'tar -xzf {} -C /var/www/html/extensions' \; \ - && find /tmp/mediawiki_skins -name "*.tar.gz" -exec sh -c 'tar -xzf {} -C /var/www/html/skins' \; \ +RUN find /tmp/mediawiki_extensions -name "*.tar.gz" -exec sh -c 'tar -xzf {} -C /var/www/html/extensions && rm {}' \; \ + && find /tmp/mediawiki_skins -name "*.tar.gz" -exec sh -c 'tar -xzf {} -C /var/www/html/skins && rm {}' \; \ && find /tmp/mediawiki_override -type f -exec php /tmp/scripts/config_placeholder_replace.php "/tmp/config.json" "{}" \; \ && cp -R /tmp/mediawiki_override/* /var/www/html \ && chown www-data:www-data /var/www/html/extensions/ -R \ diff --git a/build/scripts/mediawiki-ext-search.sh b/build/scripts/mediawiki-ext-search.sh new file mode 100755 index 0000000..5f0e26c --- /dev/null +++ b/build/scripts/mediawiki-ext-search.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Check if the correct number of arguments is provided +if [ $# -ne 2 ]; then + echo "Usage: $0 " + echo "Example: $0 Mpdf REL1_41" + exit 1 +fi + +# Extension name and version from arguments +extension_name="$1" +extension_version="$2" + +# URL to fetch +url="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=${extension_name}&extdistversion=${extension_version}" + +# Fetch the HTML content using curl +html=$(curl -s "$url") + +# Extract the download link using grep and sed +download_link=$(echo "$html" | grep -oP '