diff options
author | root <root@vps-18a7a2b7.vps.ovh.ca> | 2023-05-23 18:41:37 -0400 |
---|---|---|
committer | root <root@vps-18a7a2b7.vps.ovh.ca> | 2023-05-23 18:41:37 -0400 |
commit | 736c00e3ab6f71eadfd6bde609b3656feaa954f0 (patch) | |
tree | 2cd5d49bfa3c38326d0918582e5223ff62021e00 /wordpress | |
parent | 82c2ee534e06d92ce852f5d2965d568a649bfb72 (diff) |
wordpress-mysql to use new command
Diffstat (limited to 'wordpress')
-rwxr-xr-x | wordpress/wordpress-mysql | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/wordpress/wordpress-mysql b/wordpress/wordpress-mysql index cccc921..eca5140 100755 --- a/wordpress/wordpress-mysql +++ b/wordpress/wordpress-mysql | |||
@@ -1,63 +1,17 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | set -e | 2 | set -e |
3 | 3 | ||
4 | wp_config_get() | 4 | read_config() |
5 | { | 5 | { |
6 | sed -e 's/\r//g' -ne "s/^define( *'$1', *'\([^']*\)' *);/\1/p" < "$wp_config" | 6 | eval "$(jq -r '. | to_entries | .[] | .key + "=" + (.value | @sh) + "\n"')" |
7 | } | 7 | } |
8 | 8 | ||
9 | wp_table_prefix_get() | 9 | read_config < <(wordpress-config-info "$1") |
10 | { | ||
11 | sed -e 's/\r//g' -ne "s/^\$table_prefix *= *'\\([^']*\\)';$/\\1/p" "$wp_config" | ||
12 | } | ||
13 | |||
14 | case "$1" in | ||
15 | --table_prefix) shift; TABLE_PREFIX_ONLY=y ;; | ||
16 | --) shift ;; | ||
17 | -*) exit 1 ;; | ||
18 | esac | ||
19 | |||
20 | case "$1" in | ||
21 | '') exit 1 ;; | ||
22 | /srv/*/*/*/*) exit 1 ;; | ||
23 | /srv/*/public_html/wp-config.php) SITE_DIR=${1%/wp-config.php} ;; | ||
24 | /srv/*/*/*) exit 1 ;; | ||
25 | /srv/*/public_html) SITE_DIR=$1 ;; | ||
26 | /srv/*/*) exit 1;; | ||
27 | /srv/*) SITE_DIR=$1/public_html ;; | ||
28 | */*) exit 1 ;; | ||
29 | .*) exit 1 ;; | ||
30 | *) SITE_DIR=/srv/$1/public_html ;; | ||
31 | esac | ||
32 | |||
33 | case "$SITE_DIR" in | ||
34 | /srv/*/*/*) exit 1 ;; | ||
35 | /srv/*/public_html) [ -d "$SITE_DIR" ] ;; | ||
36 | *) exit 1 ;; | ||
37 | esac | ||
38 | |||
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 | ||
45 | [ -f "$wp_config" ] | ||
46 | |||
47 | if [ "$TABLE_PREFIX_ONLY" ] | ||
48 | then | ||
49 | wp_table_prefix_get | ||
50 | exit | ||
51 | fi | ||
52 | 10 | ||
53 | db_name=$(wp_config_get DB_NAME) | ||
54 | [ "$db_name" ] | 11 | [ "$db_name" ] |
55 | db_host=$(wp_config_get DB_HOST) | ||
56 | [ "$db_host" ] | 12 | [ "$db_host" ] |
57 | db_user=$(wp_config_get DB_USER) | ||
58 | [ "$db_user" ] | 13 | [ "$db_user" ] |
59 | db_password=$(wp_config_get DB_PASSWORD) | ||
60 | [ "$db_password" ] | 14 | [ "$db_password" ] |
61 | 15 | ||
62 | mysql --host="$db_host" --user="$db_user" --password="$db_password" "$db_name" | 16 | exec mysql --host="$db_host" --user="$db_user" --password="$db_password" "$db_name" |
63 | 17 | ||