Add automatic mediawiki extension download url parser
This commit is contained in:
parent
885b6ef7ac
commit
e302032bfd
22
Dockerfile
22
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 \
|
||||
|
30
build/scripts/mediawiki-ext-search.sh
Executable file
30
build/scripts/mediawiki-ext-search.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the correct number of arguments is provided
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 <extension_name> <extension_version>"
|
||||
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 '<a rel="nofollow" class="external free" href="\K[^"]+' | sed 's/&/\&/g')
|
||||
|
||||
# Check if the download link is found
|
||||
if [ -z "$download_link" ]; then
|
||||
echo "Download link not found for extension '$extension_name' version '$extension_version'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Print the extracted download link
|
||||
echo -n $download_link
|
Reference in New Issue
Block a user