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
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:
[Actions] ShellInAnIcon_check_opsi_version if "0" = getLastExitCode message "Doing some awesome opsi 4.1 stuff..." else isFatalError "Only usable on opsi 4.1 or newer." endif [ShellInAnIcon_check_opsi_version] 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 $?