Finding Joomla Installs and Checking Version



Published: 2017-05-15 08:02:12 +0000
Categories: BASH,

Language

BASH

Description

A small BASH script, suitable to be run as a cron job, to find Joomla installs and get the version from version.php. Can be piped into mail to generate an alert if needed

You can override the default variables by setting them within the environment. Available variables are

  • PHP - The PHP binary to call (default php5-cli)
  • VERSION_FILE - The Joomla version file to look for (default version.php)
  • WEBDIR - The directory to search within (default /home)
  • DEBUG - Enables debug mode (default n)
WEBDIR="/var/www/html"
export WEBDIR
./check_joomla_versions.sh

Snippet

#!/bin/bash
#
# Check for out-of-date installs of a specific Joomla! extension
#
# Copyright (C) 2013 B Tasker
# Released under GNU GPL V2
# See http://www.gnu.org/licenses/gpl-2.0.html
#

# Set your variables here

# The filename of the manifest file used
VERSION_FILE=${VERSION_FILE:-"version.php"}

# The directory containing all your hosting accounts
WEBDIR=${WEBDIR:-"/home"}

DEBUG=${DEBUG:-"n"}

# Processing starts
cd /tmp

# Find all relevant manifests
find "$WEBDIR" -name "$VERSION_FILE" | egrep -e "cms/|joomla/" > joomla.log

while read -r joomlasite
do

    major=`grep '$RELEASE' $joomlasite | sed 's/public//g' | sed 's/var//g'`
    minor=`grep '$DEV_LEVEL' $joomlasite  | sed 's/public//g' | sed 's/var//g'`
    fullver=`php5-cli -B "$major; $minor; echo \\$RELEASE.'.'.\\$DEV_LEVEL; exit;"`

    if [ "$fullver" == "." ]
    then
        # In Joomla 3.something these changed to constants
        major=`grep 'const RELEASE' $joomlasite | sed 's/const //g' | sed 's/\t//g'`
        minor=`grep 'const DEV_LEVEL' $joomlasite  | sed 's/const //g' | sed 's/\t//g'`
        fullver=`php5-cli -B "\\$$major; \\$$minor; echo \\$RELEASE.'.'.\\$DEV_LEVEL; exit;"`
    fi

    if [ "$DEBUG" == "y" ]
    then
      echo "DEBUG: Site is $joomlasite"
      echo "DEBUG: Major is $major"
      echo "DEBUG: Minor is $minor"
      echo "DEBUG: Release is $fullver"
    fi

    echo "$joomlasite: $fullver"

done < joomla.log

rm joomla.log

Usage Example

./check_joomla_versions.sh

Requires

  • PHP (Cli)

License

GNU GPL V2

Keywords

Joomla, Version, Checker, Script, discovery, find, cron, version.php, parse,

Latest Posts

Urldecode string (LUA)
FFMPEG Convert YUV444p to YUV420p (BASH)
Forcing FFMPEG to honour segment length in HLS Stream Creator (BASH)
Force CURL to place request to a specific IP (BASH)
Set a variable only if it is undefined (Javascript)
Ignore query string with Nginx caching proxy (NGinx)
Get breakdown of UK and non-UK votes for a Parliamentary Petition (Python)
Decompress Mozilla Firefox jsonlz4 bookmark backup files (Python)
Setting Git author details for a single repo (Git)
Checking Virtual Machine Resource Allocations with Libvirt (BASH)

Copyright © 2019 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk and snippets.6zdgh5a5e6zpchdz.onion