Advertisement
Guest User

Untitled

a guest
May 1st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # joomlafunctions.sh - general bash functions for use in my jooma scripts
  4. # Supports Joomla versions 1.0 - 3.3
  5. #
  6. # Copyright 2014 Rene Kreijveld - email@renekreijveld.nl
  7. #
  8. # This program is free software; you may redistribute it and/or modify it.
  9.  
  10. # Define general variables
  11. JOOMLACONF=./configuration.php
  12. VERSIONF1017=./includes/version.php
  13. VERSIONF1516=./libraries/joomla/version.php
  14. VERSIONF25PLUS=./libraries/cms/version/version.php
  15.  
  16. # Find MySQL Socket
  17. if [ -S /var/lib/mysql/mysql.sock ]; then
  18. MYSOCK=/var/lib/mysql/mysql.sock
  19. elif [ -S /var/run/mysqld/mysqld.sock ]; then
  20. MYSOCK=/var/run/mysqld/mysqld.sock
  21. elif [ -S /Applications/MAMP/tmp/mysql/mysql.sock ]; then
  22. MYSOCK=/Applications/MAMP/tmp/mysql/mysql.sock
  23. elif [ -S /tmp/mysql.sock ]; then
  24. MYSOCK=/tmp/mysql.sock
  25. fi
  26.  
  27. #MYSOCK=/path/to/your/socket/file/here
  28.  
  29. if [ -z MYSOCK ]; then
  30. echo "No valid MySQL socket file found!"
  31. echo "Either MySQL is not running or it is installed in a custom location."
  32. echo "Manually add it's path in this script (${MYPATH}/joomlafunctions) on line 27."
  33. exit 1
  34. fi
  35.  
  36. # Grab Joomla 1.0 information
  37. do_joomla10()
  38. {
  39. # Grab information from Joomla 1.0 configuration.
  40. sitename=`grep '$mosConfig_sitename =' ${JOOMLACONF}| cut -d \' -f 2 | sed 's/ /_/g'`
  41. sitenameclean=`grep '$mosConfig_sitename =' ${JOOMLACONF}| cut -d \' -f 2`
  42. database=`grep '$mosConfig_db =' ${JOOMLACONF} | cut -d \' -f 2`
  43. dbuser=`grep '$mosConfig_user =' ${JOOMLACONF} | cut -d \' -f 2`
  44. password=`grep '$mosConfig_password =' ${JOOMLACONF} | cut -d \' -f 2`
  45. host=`grep '$mosConfig_host =' ${JOOMLACONF} | cut -d \' -f 2`
  46. prefix=`grep '$mosConfig_dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
  47. versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
  48. versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2`
  49. verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2`
  50. }
  51.  
  52. # Grab Joomla 1.5 or 1.6 information
  53. do_joomla1516()
  54. {
  55. # Grab information from Joomla 1.5 configuration.
  56. sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
  57. sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
  58. database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
  59. dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
  60. password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
  61. host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
  62. prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
  63. versr=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2`
  64. versd=`grep '$DEV_LEVEL' ${VERSIONF1516} | cut -d \' -f 2`
  65. verss=`grep '$DEV_STATUS' ${VERSIONF1516} | cut -d \' -f 2`
  66. }
  67.  
  68. # Grab Joomla 1.7 information
  69. do_joomla17()
  70. {
  71. # Grab information from Joomla 1.5 configuration.
  72. sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
  73. sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
  74. database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
  75. dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
  76. password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
  77. host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
  78. prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
  79. versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
  80. versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2`
  81. verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2`
  82. }
  83.  
  84. # Grab Joomla 2.5 and up information
  85. do_joomla25plus()
  86. {
  87. # Grab information from Joomla 2.5/3.0/3.1/3.2 configuration.
  88. sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2 | sed 's/ /_/g'`
  89. sitenameclean=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2`
  90. database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2`
  91. dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2`
  92. password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2`
  93. host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2`
  94. prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2`
  95. versr=`grep '$RELEASE' ${VERSIONF25PLUS} | cut -d \' -f 2`
  96. versd=`grep '$DEV_LEVEL' ${VERSIONF25PLUS} | cut -d \' -f 2`
  97. verss=`grep '$DEV_STATUS' ${VERSIONF25PLUS} | cut -d \' -f 2`
  98. }
  99.  
  100. # Check if configuration.php exists.
  101. if [ ! -e ${JOOMLACONF} ]
  102. then
  103. echo "File configuration.php not found. Are you at the root of the site?"
  104. exit 1
  105. fi
  106.  
  107. # Testing for the Joomla versie
  108. if [ -e ${VERSIONF1017} ]
  109. then
  110. # Possible Joomla 1.0 or 1.7
  111. release=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2`
  112. if echo "$release" | grep -q "1.0" ; then
  113. do_joomla10
  114. fi
  115. if echo "$release" | grep -q "1.7" ; then
  116. do_joomla17
  117. fi
  118. fi
  119.  
  120. if [ -e ${VERSIONF1516} ]
  121. then
  122. # Possible Joomla 1.5 or 1.6
  123. release=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2`
  124. if echo "$release" | grep -q "1.5" ; then
  125. do_joomla1516
  126. fi
  127. if echo "$release" | grep -q "1.6" ; then
  128. do_joomla1516
  129. fi
  130. fi
  131.  
  132. # Testing for Joomla version 2.5 and up
  133. if [ -f ${VERSIONF25PLUS} ]
  134. then
  135. release=`grep '$RELEASE' ${VERSIONF25PLUS} | cut -d \' -f 2`
  136. if echo "$release" | grep -q "2.5" ; then
  137. do_joomla25plus
  138. fi
  139. if echo "$release" | grep -q "3.0" ; then
  140. do_joomla25plus
  141. fi
  142. if echo "$release" | grep -q "3.1" ; then
  143. do_joomla25plus
  144. fi
  145. if echo "$release" | grep -q "3.2" ; then
  146. do_joomla25plus
  147. fi
  148. if echo "$release" | grep -q "3.3" ; then
  149. do_joomla25plus
  150. fi
  151. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement