opsi-script: Checking for opsi 4.1

Since this week public repositories for opsi 4.1 are available and now is a good time to prepare for the switch to opsi 4.1. If you are using opsi to also manage your opsi servers there is a chance that you may want to distinguish between servers running opsi 4.0 and opsi 4.1.

This was the case as I was working on some opsi script that makes use of the new .repo file feature in opsi 4.1 for easy configuration of opsi-package-updater.

In case the script is run on a server that does not support this feature I wanted to abort with a meaningful message.

This is what I came up with:

if "0" = getLastExitCode
    message "Doing some awesome opsi 4.1 stuff..."
    isFatalError "Only usable on opsi 4.1 or newer."

set -x
export PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin
python -c "from OPSI import __version__ as v; print(v)"
exit $?