summaryrefslogtreecommitdiff
path: root/wordpress
diff options
context:
space:
mode:
authorroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-23 18:41:37 -0400
committerroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-23 18:41:37 -0400
commit736c00e3ab6f71eadfd6bde609b3656feaa954f0 (patch)
tree2cd5d49bfa3c38326d0918582e5223ff62021e00 /wordpress
parent82c2ee534e06d92ce852f5d2965d568a649bfb72 (diff)
wordpress-mysql to use new command
Diffstat (limited to 'wordpress')
-rwxr-xr-xwordpress/wordpress-mysql54
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
2set -e 2set -e
3 3
4wp_config_get() 4read_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
9wp_table_prefix_get() 9read_config < <(wordpress-config-info "$1")
10{
11 sed -e 's/\r//g' -ne "s/^\$table_prefix *= *'\\([^']*\\)';$/\\1/p" "$wp_config"
12}
13
14case "$1" in
15 --table_prefix) shift; TABLE_PREFIX_ONLY=y ;;
16 --) shift ;;
17 -*) exit 1 ;;
18esac
19
20case "$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 ;;
31esac
32
33case "$SITE_DIR" in
34 /srv/*/*/*) exit 1 ;;
35 /srv/*/public_html) [ -d "$SITE_DIR" ] ;;
36 *) exit 1 ;;
37esac
38
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
45[ -f "$wp_config" ]
46
47if [ "$TABLE_PREFIX_ONLY" ]
48then
49 wp_table_prefix_get
50 exit
51fi
52 10
53db_name=$(wp_config_get DB_NAME)
54[ "$db_name" ] 11[ "$db_name" ]
55db_host=$(wp_config_get DB_HOST)
56[ "$db_host" ] 12[ "$db_host" ]
57db_user=$(wp_config_get DB_USER)
58[ "$db_user" ] 13[ "$db_user" ]
59db_password=$(wp_config_get DB_PASSWORD)
60[ "$db_password" ] 14[ "$db_password" ]
61 15
62mysql --host="$db_host" --user="$db_user" --password="$db_password" "$db_name" 16exec mysql --host="$db_host" --user="$db_user" --password="$db_password" "$db_name"
63 17