forked from mirromutth/mysql-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·33 lines (24 loc) · 1.09 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
docker_run="docker run"
if [ -n "$INPUT_MYSQL_ROOT_PASSWORD" ]; then
echo "Root password not empty, use root superuser"
docker_run="$docker_run -e MYSQL_ROOT_PASSWORD=$INPUT_MYSQL_ROOT_PASSWORD"
elif [ -n "$INPUT_MYSQL_USER" ]; then
if [ -z "$INPUT_MYSQL_PASSWORD" ]; then
echo "The mysql password must not be empty when mysql user exists"
exit 1
fi
echo "Use specified user and password"
docker_run="$docker_run -e MYSQL_RANDOM_ROOT_PASSWORD=true -e MYSQL_USER=$INPUT_MYSQL_USER -e MYSQL_PASSWORD=$INPUT_MYSQL_PASSWORD"
else
echo "Both root password and superuser are empty, must contains one superuser"
exit 1
fi
if [ -n "$INPUT_MYSQL_DATABASE" ]; then
echo "Use specified database"
docker_run="$docker_run -e MYSQL_DATABASE=$INPUT_MYSQL_DATABASE"
fi
docker_run="$docker_run -d -p $INPUT_HOST_PORT:$INPUT_CONTAINER_PORT mysql:$INPUT_MYSQL_VERSION --port=$INPUT_CONTAINER_PORT"
docker_run="$docker_run --character-set-server=$INPUT_CHARACTER_SET_SERVER --collation-server=$INPUT_COLLATION_SERVER"
docker_run="$docker_run --sql-mode=$INPUT_SQL_MODE"
sh -c "$docker_run"