summaryrefslogtreecommitdiff
path: root/wordpress
diff options
context:
space:
mode:
authorroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-28 13:21:10 -0400
committerroot <root@vps-18a7a2b7.vps.ovh.ca>2023-05-28 13:21:10 -0400
commit4f050f196a3409dd79b09c607bef19364a42baab (patch)
tree4ea8f3f4a4aafc515d71f9ef291f99f031a2572b /wordpress
parent291d8b9c32e4dac1c4794444ca5bfc005f454dda (diff)
wordpress-mysq: option $DO_NOT_USE_SSH respected when creating local new database
Diffstat (limited to 'wordpress')
-rwxr-xr-xwordpress/wordpress-mysql31
1 files changed, 21 insertions, 10 deletions
diff --git a/wordpress/wordpress-mysql b/wordpress/wordpress-mysql
index a9b0d21..a96b8e4 100755
--- a/wordpress/wordpress-mysql
+++ b/wordpress/wordpress-mysql
@@ -6,15 +6,29 @@ read_config()
6 eval "$(jq -r '. | to_entries | .[] | .key + "=" + (.value | @sh) + "\n"')" 6 eval "$(jq -r '. | to_entries | .[] | .key + "=" + (.value | @sh) + "\n"')"
7} 7}
8 8
9have_database() 9our_mysqladmin()
10{ 10{
11 if [ "$DO_NOT_USE_SSH" ] 11 if [ "$DO_NOT_USE_SSH" ]
12 then 12 then
13 set -- mysql --host="$db_host" 13 mysqladmin "$@"
14 else 14 else
15 set -- ssh "$db_host" -- mysql 15 ssh -- "$db_host" mysqladmin "$@"
16 fi 16 fi
17 "$@" -ss <<END | (read match && [ "$match" ]) 17}
18
19our_mysql()
20{
21 if [ "$DO_NOT_USE_SSH" ]
22 then
23 mysql --host="$db_host" "$@"
24 else
25 ssh -- "$db_host" mysql "$@"
26 fi
27}
28
29have_database()
30{
31 our_mysql -ss <<END | (read match && [ "$match" ])
18show databases where \`database\` = '${db_name//\'/\'\'}' 32show databases where \`database\` = '${db_name//\'/\'\'}'
19END 33END
20} 34}
@@ -22,8 +36,8 @@ END
22create_new_mysql_database() 36create_new_mysql_database()
23{ 37{
24 [ "$db_host" ] 38 [ "$db_host" ]
25 ssh -- "$db_host" mysqladmin create "$db_name" 39 our_mysqladmin create "$db_name"
26 ssh -- "$db_host" mysql "$db_name" <<END 40 our_mysql "$db_name" <<END
27grant all privileges on \`$db_name\`.* to "$db_user" identified by "$db_password"; 41grant all privileges on \`$db_name\`.* to "$db_user" identified by "$db_password";
28END 42END
29} 43}
@@ -67,10 +81,7 @@ then
67 echo "$0: Warning: create_new_mysql_database: skipped" >&2 81 echo "$0: Warning: create_new_mysql_database: skipped" >&2
68 fi 82 fi
69 exit 83 exit
70elif [ "$DO_NOT_USE_SSH" ]
71then
72 exec mysql --host="$db_host" --user="$db_user" --password="$db_password" "$db_name"
73else 84else
74 exec ssh -- "$db_host" mysql --user="$db_user" --password="$db_password" "$db_name" 85 our_mysql --user="$db_user" --password="$db_password" "$db_name"
75fi 86fi
76 87