JP Vossen on 14 Mar 2013 12:15:56 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] finding joomla version at the command line


Date: Thu, 14 Mar 2013 14:38:55 -0400
From: Michael Lazin<microlaser@gmail.com>

I like to check what version of a cms a user is using sometimes.  With
wordpress it's easy, you can do "find -name version.php | xargs grep
wp_version" and it will spit out the version name and the path.  I'm trying
to do the same with Joomla, I've tried some variations on this with both
grep and egrep with no success.  The same name file tells the Joomla
version, version.php, but the release information is in two different
fields, like so:

         var $RELEASE    = '1.5';
         /** @var string Development Status */
         var $DEV_STATUS = 'Stable';
         /** @var int Sub Release Level */
         var $DEV_LEVEL  = '26';
         /** @var int build Number */
         var $BUILD      = '';

Can any one think of a clever variation of my first command that will show
both $RELEASE $DEV_LEVEL using a similar variation of egrep or grep?  For
some reason I just can't get it right now.

Here is a shell function I wrote (cheating and using Perl) to do that circa 2008; based on above I *think* it'll still work:

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Return (print) the current running version of Joomla
# Called like:  get_current_ver </path/to/ Joomla version.php>
# e.g., get_current_ver "$web_root_dir/joomla/libraries/joomla/version.php"
function get_current_ver {
    # Old, cheesy
# perl -ne 'print qq($1\n) if m/([0-9.]+) Stable Release/;' /var/www/joomla/CHANGELOG.php | head -n1
    # More work, but more likely to be correct
    perl -e 'while (<>) {
                  $release = $1 if m/var \$RELEASE\s+= .([\d.]+).;/;
                  $dev     = $1 if m/var \$DEV_LEVEL\s+= .(\d+).;/;
              }
              print qq($release.$dev\n);' $1
} # end of get_current_ver

Used like:
web_root_dir='/var/www'             # Actual Joomla dir in here
joomla_package_dir='/root/Joomla'   # Joomla packages and patches
joomla_version_file="$web_root_dir/joomla/libraries/joomla/version.php"
current_ver=$(get_current_ver $joomla_version_file) # What are we running now


HTH,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug