summaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
authorroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-22 22:47:21 -0400
committerroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-22 22:47:21 -0400
commitf72a817ce23a60467b6a654ad8ae7d0803fba28d (patch)
treee5d4832086811e6d7b128a2a11dfd93e857b35fe /other
parentac729728f372713dfd0262d93cc0ba6f401e7797 (diff)
increase robustness to varying site configurations
Diffstat (limited to 'other')
-rwxr-xr-xother/wordpress-mysql21
1 files changed, 14 insertions, 7 deletions
diff --git a/other/wordpress-mysql b/other/wordpress-mysql
index 5c69693..cccc921 100755
--- a/other/wordpress-mysql
+++ b/other/wordpress-mysql
@@ -3,12 +3,12 @@ set -e
3 3
4wp_config_get() 4wp_config_get()
5{ 5{
6 sed -n "s/^define( *'$1', *'\([^']*\)' *);/\1/p" < "$wp_config" 6 sed -e 's/\r//g' -ne "s/^define( *'$1', *'\([^']*\)' *);/\1/p" < "$wp_config"
7} 7}
8 8
9wp_table_prefix_get() 9wp_table_prefix_get()
10{ 10{
11 sed -ne "s/^\$table_prefix *= *'\\([^']*\\)';$/\\1/p" "$wp_config" 11 sed -e 's/\r//g' -ne "s/^\$table_prefix *= *'\\([^']*\\)';$/\\1/p" "$wp_config"
12} 12}
13 13
14case "$1" in 14case "$1" in
@@ -17,15 +17,17 @@ case "$1" in
17 -*) exit 1 ;; 17 -*) exit 1 ;;
18esac 18esac
19 19
20case "${1%/}" in 20case "$1" in
21 '') exit 1 ;; 21 '') exit 1 ;;
22 /srv/*/*/*/*) exit 1 ;;
23 /srv/*/public_html/wp-config.php) SITE_DIR=${1%/wp-config.php} ;;
22 /srv/*/*/*) exit 1 ;; 24 /srv/*/*/*) exit 1 ;;
23 /srv/*/public_html) SITE_DIR=${1%/} ;; 25 /srv/*/public_html) SITE_DIR=$1 ;;
24 /srv/*/*) exit 1;; 26 /srv/*/*) exit 1;;
25 /srv/*) SITE_DIR=${1%/}/public_html ;; 27 /srv/*) SITE_DIR=$1/public_html ;;
26 */*) exit 1 ;; 28 */*) exit 1 ;;
27 .*) exit 1 ;; 29 .*) exit 1 ;;
28 *) SITE_DIR=/srv/${1%/}/public_html ;; 30 *) SITE_DIR=/srv/$1/public_html ;;
29esac 31esac
30 32
31case "$SITE_DIR" in 33case "$SITE_DIR" in
@@ -34,7 +36,12 @@ case "$SITE_DIR" in
34 *) exit 1 ;; 36 *) exit 1 ;;
35esac 37esac
36 38
37wp_config=$SITE_DIR/wordpress/wp-config.php 39if [ -d "$SITE_DIR"/wordpress ]
40then
41 wp_config=$SITE_DIR/wordpress/wp-config.php
42else
43 wp_config=$SITE_DIR/wp-config.php
44fi
38[ -f "$wp_config" ] 45[ -f "$wp_config" ]
39 46
40if [ "$TABLE_PREFIX_ONLY" ] 47if [ "$TABLE_PREFIX_ONLY" ]