This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
docker-mediawiki/build/scripts/mediawiki-ext-search.sh

31 lines
893 B
Bash
Raw Normal View History

#!/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/&amp;/\&/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