Checking Unraid version


itimpi

6 posts in this topic Last Reply

Recommended Posts

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 :)

Link to post
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

Link to post
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.

Link to post

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 by SimonF
Link to post

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
}

 

  • Like 1
  • Thanks 1
Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.