Last active
August 4, 2020 13:48
-
-
Save breiter/1c01ae6ee49a4f245ffb49ef31fdff97 to your computer and use it in GitHub Desktop.
Script to install/update mono for mac from canonical official pkg installer on download.mono-project.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
current_userid=$(id -u) | |
if [ $current_userid -ne 0 ]; then | |
echo "$(basename "$0") requires superuser privileges to run" >&2 | |
exit 1 | |
fi | |
INSTALLED_VERSION=$(mono --version 2> /dev/null | grep -o -E 'version [0-9\.]+'| grep -o -E [0-9\.]+) | |
STABLE_VERSION=$(curl -s https://www.mono-project.com/download/stable/ | grep -o -E 'Stable \(.+\)' | grep -E -o '[0-9\.]+') | |
do_install() { | |
MAJOR_VERSION=$(echo $STABLE_VERSION | grep -o -E '([0-9\]+\.){,3}' | cut -d'.' -f1-3) | |
URL="https://download.mono-project.com/archive/${MAJOR_VERSION}/macos-10-universal/" | |
FILE="MonoFramework-MDK-${STABLE_VERSION}.macos10.xamarin.universal.pkg" | |
echo "Downloading mono ${STABLE_VERSION} pkg installer." | |
curl "${URL}${FILE}" > "/tmp/${FILE}" | |
echo "Installing mono ${STABLE_VERSION}" | |
installer -pkg "/tmp/${FILE}" -target / | |
rm "/tmp/${FILE}" | |
eval $(/usr/libexec/path_helper -s) | |
} | |
if [ "$INSTALLED_VERSION" = "$STABLE_VERSION" ]; then | |
echo "mono $INSTALLED_VERSION is up to date." | |
else | |
do_install | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment