Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 3833420

Browse files
committed
Native mysql command.
1 parent 6daf379 commit 3833420

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

bin/mysql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
check_image()
4+
{
5+
# VERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='wplib/{{.Label "container.name"}}:{{.Label "container.version"}}' 2>/dev/null`"
6+
VERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='{{.Label "container.version"}}' 2>/dev/null`"
7+
8+
if [ "$VERSION" == "" ]
9+
then
10+
echo "WPLib: No MySQL database running."
11+
return 1
12+
fi
13+
14+
MAJORVERSION="`docker container ls -af label=container.class="database" -f "status=running" --format='{{.Label "container.majorversion"}}' 2>/dev/null`"
15+
IP="`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-${VERSION}`"
16+
17+
return 0
18+
}
19+
20+
21+
if check_image
22+
then
23+
exec box container shell wplib/mysql:${MAJORVERSION} mysql -h ${IP} "$@"
24+
fi
25+

0 commit comments

Comments
 (0)