Skip to content

Instantly share code, notes, and snippets.

@nimatrueway
Last active August 30, 2023 20:44
Show Gist options
  • Save nimatrueway/8f13a3f5d7d3599dbba9b48cbb1bb1d3 to your computer and use it in GitHub Desktop.
Save nimatrueway/8f13a3f5d7d3599dbba9b48cbb1bb1d3 to your computer and use it in GitHub Desktop.
Mendix downloader for Linux/macOS/Unix
#!/bin/bash
#
# Description:
# downloads mendix of the specified version and places it in `$HOME/.mendix/{{specified-version}}`
#
# Usage:
# mendix-downloader.sh {{specify-the-desired-version}}
# (e.g. mendix-downloader.sh 7.23.7.55882)
#
MXBUILD_VERSION=$1
MENDIX_INSTALL_PATH_ROOT="$HOME/.mendix"
MENDIX_INSTALL_PATH="$MENDIX_INSTALL_PATH_ROOT/$MXBUILD_VERSION"
function download() {
URL=$1
OUTPUT=$2
if hash axel 2>/dev/null; then
axel -a -n 16 "$URL" -o "$OUTPUT"
elif hash aria2c 2>/dev/null; then
aria2c -d "$(dirname "$OUTPUT")" -o "$(basename "$OUTPUT")" -s 16 "$URL"
elif hash wget 2>/dev/null; then
wget -q --show-progress -L -o "$OUTPUT" "$URL"
elif hash curl 2>/dev/null; then
curl -L "$URL" -o "$OUTPUT"
else
echo "Neither of axel/aria2c/wget/curl tools found for downloading!"
exit 1
fi
}
# check if version argument is passed
if [[ "" == "$MXBUILD_VERSION" ]]; then
echo "Input your desired version (e.g. \"7.23.7.55882\")."
echo "You can find available version from here: https://appstore.home.mendix.com/link/modelers/"
exit 0
fi
# create install path
if [[ ! -d $MENDIX_INSTALL_PATH ]]; then
mkdir -p $MENDIX_INSTALL_PATH
fi
# remove previously downloaded archives
find "$MENDIX_INSTALL_PATH" -maxdepth 1 -name "*.tar.gz" -delete
# download mxbuild / mendix
download "https://cdn.mendix.com/runtime/mxbuild-$MXBUILD_VERSION.tar.gz" "$MENDIX_INSTALL_PATH/mxbuild.tar.gz"
download "https://artifacts.rnd.mendix.com/runtimes/mendix-$MXBUILD_VERSION.tar.gz" "$MENDIX_INSTALL_PATH/mendix.tar.gz"
# extract mxbuild
tar xf "$MENDIX_INSTALL_PATH/mxbuild.tar.gz" -C "$MENDIX_INSTALL_PATH"
# extract mendix
tar xf "$MENDIX_INSTALL_PATH/mendix.tar.gz" \
-C "$MENDIX_INSTALL_PATH/runtime" \
"$MXBUILD_VERSION/runtime/launcher" \
"$MXBUILD_VERSION/runtime/lib" \
"--strip-components=2"
# make mono.exe files as executable
find "$MENDIX_INSTALL_PATH/modeler" -name '*.exe' -exec chmod +x {} \;
# remove previously downloaded archives
find "$MENDIX_INSTALL_PATH" -maxdepth 1 -name "*.tar.gz" -delete
@nimatrueway
Copy link
Author

nimatrueway commented Jul 20, 2020

To install the script:

curl -O https://gist.githubusercontent.com/nimatrueway/8f13a3f5d7d3599dbba9b48cbb1bb1d3/raw/mendix-downloader.sh && sudo install mendix-downloader.sh /usr/bin/mendix-downloader

usage:

mendix-downloader {{specify-the-desired-version}}

@nimatrueway
Copy link
Author

nimatrueway commented Aug 7, 2020

To directly use the script:

bash <(curl https://gist.githubusercontent.com/nimatrueway/8f13a3f5d7d3599dbba9b48cbb1bb1d3/raw/mendix-downloader.sh) {{specify-the-desired-version}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment