Skip to content

Instantly share code, notes, and snippets.

@renekreijveld
Last active June 12, 2018 07:22
Show Gist options
  • Save renekreijveld/9663741 to your computer and use it in GitHub Desktop.
Save renekreijveld/9663741 to your computer and use it in GitHub Desktop.
General bash functions for use in jooma scripts
#!/bin/sh
# jfunctions - general bash functions for use in Joomla bash scripts
# Supports Joomla versions 2.5 - 3.x
#
# Copyright 2014 - 2016 Rene Kreijveld - [email protected]
#
# This program is free software; you may redistribute it and/or modify it.
#
# Version history
# 3.0 Initial version
# 3.1 Code rewrite
# 3.2 Modification of all echo -e statements and remove backticks
# 3.3 Update to support Joomla 3.5
# 3.4 Dropped support for Joomla versions lower than 2.5
# Define general variables
version=3.4
# Check if configuration.php exists.
if [ ! -e ./configuration.php ]
then
echo ""
echo "File configuration.php not found. Are you at the root of the site?"
echo ""
exit 1
fi
# Find MySQL Socket
if [ -S /var/lib/mysql/mysql.sock ]; then
mysock=/var/lib/mysql/mysql.sock
elif [ -S /var/run/mysqld/mysqld.sock ]; then
mysock=/var/run/mysqld/mysqld.sock
elif [ -S /Applications/MAMP/tmp/mysql/mysql.sock ]; then
mysock=/Applications/MAMP/tmp/mysql/mysql.sock
elif [ -S /tmp/mysql.sock ]; then
mysock=/tmp/mysql.sock
fi
# Grab information from Joomla 2.5/3.x configuration.
sitename=$(grep '$sitename =' ./configuration.php | cut -d \' -f 2 | sed 's/ /_/g')
sitenameclean=$(grep '$sitename =' ./configuration.php | cut -d \' -f 2)
database=$(grep '$db =' ./configuration.php | cut -d \' -f 2)
dbuser=$(grep '$user =' ./configuration.php | cut -d \' -f 2)
password=$(grep '$password =' ./configuration.php | cut -d \' -f 2)
host=$(grep '$host =' ./configuration.php | cut -d \' -f 2)
prefix=$(grep '$dbprefix =' ./configuration.php | cut -d \' -f 2)
versr=$(grep 'RELEASE =' ./libraries/cms/version/version.php | cut -d \' -f 2)
versd=$(grep 'DEV_LEVEL =' ./libraries/cms/version/version.php | cut -d \' -f 2)
verss=$(grep 'DEV_STATUS =' ./libraries/cms/version/version.php | cut -d \' -f 2)
@AnatolBu
Copy link

Thanks for the great script. I´ve did a quick test with 3.4 which worked well.
if echo "$release" | grep -q "3.4" ; then
had to been added.

@ZerooCool
Copy link

Can you upp with 3.4 and 3.5 and 3.5.1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment