itimpi Posted November 29, 2020 Share Posted November 29, 2020 To save me writing my own I was wondering if there is a standard PHP routine in Unraid that I can use to check that the Unraid version meets the requirements for a new feature I am adding to a plugin (needs to be Unraid 6.9.0 beta 36 or higher). Ideally this routine would handle both stable and next type releases. It feels like a routine that may already be present somewhere if I could just locate it Quote Link to comment
SimonF Posted November 29, 2020 Share Posted November 29, 2020 21 minutes ago, itimpi said: To save me writing my own I was wondering if there is a standard PHP routine in Unraid that I can use to check that the Unraid version meets the requirements for a new feature I am adding to a plugin (needs to be Unraid 6.9.0 beta 36 or higher). Ideally this routine would handle both stable and next type releases. It feels like a routine that may already be present somewhere if I could just locate it Can you not just use [var] => Array ( [version] => 6.9.0-beta35 Quote Link to comment
itimpi Posted November 29, 2020 Author Share Posted November 29, 2020 16 minutes ago, SimonF said: Can you not just use [var] => Array ( [version] => 6.9.0-beta35 does that work correctly for detecting that 6.9.0 (i. e. stable version) is greater than any beta or rc release and rc releases are greater than beta ones? I had not thought of doing it that way so maybe I should try it to see as it is a very simple way if it works. Since I do not intend to release this new feature until 6.9.0 beta 36 (or later) is released I could probably get away in practice in just checking for the 6.9.09 part of the release info, but I thought the question war worth asking anyway. Quote Link to comment
SimonF Posted November 29, 2020 Share Posted November 29, 2020 (edited) Found this code in Squid's CA helpders. ################################################################# # checks the Min/Max version of an app against unRaid's version # # Returns: TRUE if it's valid to run, FALSE if not # ################################################################# function versionCheck($template) { global $caSettings; if ( $template['MinVer'] && ( version_compare($template['MinVer'],$caSettings['unRaidVersion']) > 0 ) ) return false; if ( $template['MaxVer'] && ( version_compare($template['MaxVer'],$caSettings['unRaidVersion']) < 0 ) ) return false; return true; } Also version is available here. root@Tower:/etc# cat unraid-version version="6.9.0-beta35" Edited November 29, 2020 by SimonF Quote Link to comment
itimpi Posted November 29, 2020 Author Share Posted November 29, 2020 Looks like version_compare() is a standard PHP function that does what I want. Quote Link to comment
Squid Posted November 29, 2020 Share Posted November 29, 2020 You want to use version_compare $unraid = parse_ini_file("/etc/unraid-version"); if ( version_compare($unraid['version'],"6.9.0-beta35",">") ) { we're running beta36+ } else { we're running <= beta35 } 1 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.