Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # joomlafunctions.sh - general bash functions for use in my jooma scripts
- # Supports Joomla versions 1.0 - 3.3
- #
- # Copyright 2014 Rene Kreijveld - email@renekreijveld.nl
- #
- # This program is free software; you may redistribute it and/or modify it.
- # Define general variables
- JOOMLACONF=./configuration.php
- VERSIONF1017=./includes/version.php
- VERSIONF1516=./libraries/joomla/version.php
- VERSIONF25PLUS=./libraries/cms/version/version.php
- # 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
- #MYSOCK=/path/to/your/socket/file/here
- if [ -z MYSOCK ]; then
- echo "No valid MySQL socket file found!"
- echo "Either MySQL is not running or it is installed in a custom location."
- echo "Manually add it's path in this script (${MYPATH}/joomlafunctions) on line 27."
- exit 1
- fi
- # Grab Joomla 1.0 information
- do_joomla10()
- {
- # Grab information from Joomla 1.0 configuration.
- sitename=`grep '$mosConfig_sitename =' ${JOOMLACONF}| cut -d \' -f 2 | sed 's/ /_/g'`
- sitenameclean=`grep '$mosConfig_sitename =' ${JOOMLACONF}| cut -d \' -f 2`
- database=`grep '$mosConfig_db =' ${JOOMLACONF} | cut -d \' -f 2`
- dbuser=`grep '$mosConfig_user =' ${JOOMLACONF} | cut -d \' -f 2`
- password=`grep '$mosConfig_password =' ${JOOMLACONF} | cut -d \' -f 2`
- host=`grep '$mosConfig_host =' ${JOOMLACONF} | cut -d \' -f 2`
- prefix=`grep '$mosConfig_dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
- versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
- versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2`
- verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2`
- }
- # Grab Joomla 1.5 or 1.6 information
- do_joomla1516()
- {
- # Grab information from Joomla 1.5 configuration.
- sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
- sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
- database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
- dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
- password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
- host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
- prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
- versr=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2`
- versd=`grep '$DEV_LEVEL' ${VERSIONF1516} | cut -d \' -f 2`
- verss=`grep '$DEV_STATUS' ${VERSIONF1516} | cut -d \' -f 2`
- }
- # Grab Joomla 1.7 information
- do_joomla17()
- {
- # Grab information from Joomla 1.5 configuration.
- sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
- sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
- database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
- dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
- password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
- host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
- prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
- versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
- versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2`
- verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2`
- }
- # Grab Joomla 2.5 and up information
- do_joomla25plus()
- {
- # Grab information from Joomla 2.5/3.0/3.1/3.2 configuration.
- sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
- sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
- database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
- dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
- password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
- host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
- prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
- versr=`grep '$RELEASE' ${VERSIONF25PLUS} | cut -d \' -f 2`
- versd=`grep '$DEV_LEVEL' ${VERSIONF25PLUS} | cut -d \' -f 2`
- verss=`grep '$DEV_STATUS' ${VERSIONF25PLUS} | cut -d \' -f 2`
- }
- # Check if configuration.php exists.
- if [ ! -e ${JOOMLACONF} ]
- then
- echo "File configuration.php not found. Are you at the root of the site?"
- exit 1
- fi
- # Testing for the Joomla versie
- if [ -e ${VERSIONF1017} ]
- then
- # Possible Joomla 1.0 or 1.7
- release=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
- if echo "$release" | grep -q "1.0" ; then
- do_joomla10
- fi
- if echo "$release" | grep -q "1.7" ; then
- do_joomla17
- fi
- fi
- if [ -e ${VERSIONF1516} ]
- then
- # Possible Joomla 1.5 or 1.6
- release=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2`
- if echo "$release" | grep -q "1.5" ; then
- do_joomla1516
- fi
- if echo "$release" | grep -q "1.6" ; then
- do_joomla1516
- fi
- fi
- # Testing for Joomla version 2.5 and up
- if [ -f ${VERSIONF25PLUS} ]
- then
- release=`grep '$RELEASE' ${VERSIONF25PLUS} | cut -d \' -f 2`
- if echo "$release" | grep -q "2.5" ; then
- do_joomla25plus
- fi
- if echo "$release" | grep -q "3.0" ; then
- do_joomla25plus
- fi
- if echo "$release" | grep -q "3.1" ; then
- do_joomla25plus
- fi
- if echo "$release" | grep -q "3.2" ; then
- do_joomla25plus
- fi
- if echo "$release" | grep -q "3.3" ; then
- do_joomla25plus
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement