diff options
author | root <root@vps-18a7a2b7.vps.ovh.ca> | 2023-05-22 22:47:21 -0400 |
---|---|---|
committer | root <root@vps-18a7a2b7.vps.ovh.ca> | 2023-05-22 22:47:21 -0400 |
commit | f72a817ce23a60467b6a654ad8ae7d0803fba28d (patch) | |
tree | e5d4832086811e6d7b128a2a11dfd93e857b35fe /other | |
parent | ac729728f372713dfd0262d93cc0ba6f401e7797 (diff) |
increase robustness to varying site configurations
Diffstat (limited to 'other')
-rwxr-xr-x | other/wordpress-mysql | 21 |
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 | ||
4 | wp_config_get() | 4 | wp_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 | ||
9 | wp_table_prefix_get() | 9 | wp_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 | ||
14 | case "$1" in | 14 | case "$1" in |
@@ -17,15 +17,17 @@ case "$1" in | |||
17 | -*) exit 1 ;; | 17 | -*) exit 1 ;; |
18 | esac | 18 | esac |
19 | 19 | ||
20 | case "${1%/}" in | 20 | case "$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 ;; |
29 | esac | 31 | esac |
30 | 32 | ||
31 | case "$SITE_DIR" in | 33 | case "$SITE_DIR" in |
@@ -34,7 +36,12 @@ case "$SITE_DIR" in | |||
34 | *) exit 1 ;; | 36 | *) exit 1 ;; |
35 | esac | 37 | esac |
36 | 38 | ||
37 | wp_config=$SITE_DIR/wordpress/wp-config.php | 39 | if [ -d "$SITE_DIR"/wordpress ] |
40 | then | ||
41 | wp_config=$SITE_DIR/wordpress/wp-config.php | ||
42 | else | ||
43 | wp_config=$SITE_DIR/wp-config.php | ||
44 | fi | ||
38 | [ -f "$wp_config" ] | 45 | [ -f "$wp_config" ] |
39 | 46 | ||
40 | if [ "$TABLE_PREFIX_ONLY" ] | 47 | if [ "$TABLE_PREFIX_ONLY" ] |