Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active Aug 4, 2020
Embed
What would you like to do?
Script to install/update mono for mac from canonical official pkg installer on download.mono-project.com
#!/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