50 lines
1.7 KiB
Bash
Executable File
50 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Make sure the user has a sufficiently recent version of mono on the PATH
|
|
MINIMUM_MONO_VERSION="4.2"
|
|
|
|
make_version() {
|
|
echo "$1" | tr '.' '\n' | head -n 4 | xargs printf "%03d%03d%03d%03d";
|
|
}
|
|
|
|
mono_missing_or_old() {
|
|
command -v mono >/dev/null 2>&1 || return 0
|
|
MONO_VERSION=$(mono --version | head -n1 | cut -d' ' -f5)
|
|
[ "$(make_version "${MONO_VERSION}")" -lt "$(make_version "${MINIMUM_MONO_VERSION}")" ] && return 0
|
|
return 1
|
|
}
|
|
|
|
if mono_missing_or_old; then
|
|
ERROR_MESSAGE="{MODNAME} requires Mono ${MINIMUM_MONO_VERSION} or greater.\nPlease install Mono using your system package manager."
|
|
if command -v zenity > /dev/null; then
|
|
zenity --no-wrap --error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null
|
|
elif command -v kdialog > /dev/null; then
|
|
kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}"
|
|
else
|
|
printf "${ERROR_MESSAGE}"
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
# Some distros and self-compiled mono installations don't set up
|
|
# the SSL required for http web queries. If we detect that these
|
|
# are missing we can try and create a local sync as a fallback.
|
|
if [ ! -d "/usr/share/.mono/certs" ] && [ ! -d "~/.config/.mono/certs" ]; then
|
|
if [ -f "/etc/pki/tls/certs/ca-bundle.crt" ]; then
|
|
cert-sync --quiet --user /etc/pki/tls/certs/ca-bundle.crt
|
|
elif [ -f "/etc/ssl/certs/ca-certificates.crt" ]; then
|
|
cert-sync --quiet --user /etc/ssl/certs/ca-certificates.crt
|
|
fi
|
|
fi
|
|
|
|
# Run the game or server
|
|
HERE="$(dirname "$(readlink -f "${0}")")"
|
|
export PATH="${HERE}"/usr/bin/:"${PATH}"
|
|
export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}"
|
|
|
|
if [ -n "$1" ] && [ "$1" = "--server" ]; then
|
|
exec "openra-{MODID}-server" "$@"
|
|
else
|
|
exec "openra-{MODID}" "$@"
|
|
fi
|