Skip to content

Instantly share code, notes, and snippets.

@kaloyan-raev
Last active November 18, 2015 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaloyan-raev/06c363ec7337aed574dc to your computer and use it in GitHub Desktop.
Save kaloyan-raev/06c363ec7337aed574dc to your computer and use it in GitHub Desktop.
Bash script for mirroring the Zend Studio update site
#!/bin/bash
##############################################################################
# Configuration
##############################################################################
# The version of Zend Studio
version="13.0.1"
#
# The MD5 checksum of the zipped update site.
# It can be found on the zend.com download page.
checksum="19a9b59567f32dc082c691d850c922fe"
#
# The URL of the mirrored update site in your local intranet.
local_url="http://10.1.2.3/updates"
##############################################################################
# Don't change this variable. This is the name of the zipped update site file, calculated from the $version variable.
zip_package_name="ZendStudio-$version-update-site.zip"
# Don't change this variable. This is the URL for downloading the zipped update site file, calculated from the $version variable.
download_url="http://downloads.zend.com/studio-eclipse/$version/$zip_package_name"
# Verifies if $TMPDIR is set
if [ -z $TMPDIR ]; then
>&2 echo "Fatal error: \$TMPDIR is not set."
exit 1;
fi
# Downloads the ZIP archive.
# Remove the --quite option to display progress.
echo "Downloading $download_url ..."
wget $download_url -O "$TMPDIR/$zip_package_name" --quiet
if [ $? -ne 0 ]; then
# The download completed with error.
>&2 echo "Fatal error: Error during download."
exit 1;
fi
echo "Download completed: $TMPDIR/$zip_package_name."
# Verifies the MD5 checksum of the downloaded ZIP archive.
# Remove --quite and --status options for detailed output.
echo "$checksum $TMPDIR/$zip_package_name" > "$TMPDIR/checksum.txt"
md5sum --check --quiet --status "$TMPDIR/checksum.txt"
if [ $? -ne 0 ]; then
# The checksum does not match.
>&2 echo "Fatal error: MD5 checksum does not match. The download is incomplete."
exit 1;
fi
# Extracts the downloaded ZIP archive.
echo "Extracting contents..."
unzip -qo "$TMPDIR/$zip_package_name"
if [ $? -ne 0 ]; then
# The extraction completed with error.
>&2 echo "Fatal error: Error during extraction."
exit 1;
fi
echo "Extraction completed."
# Replaces the URL for Add-Ons catalog metadata to point to the URL of the mirrored update site.
sed --in-place "s@http://downloads.zend.com/.*catalog.jar@$local_url/catalog.jar@g" directory.xml
if [ $? -ne 0 ]; then
# Modifying directory.xml completed with error.
>&2 echo "Fatal error: Could not modify directory.xml."
exit 1;
fi
echo "directory.xml modified successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment