Browse Source

fixed mariadb upgrade

master
Lukasz Jarosz 5 years ago
parent
commit
680e9cf0e8
3 changed files with 13 additions and 21 deletions
  1. 1
    1
      Dockerfile
  2. 9
    0
      files/etc/s6/mariadb-upgrade/run
  3. 3
    20
      files/etc/s6/mariadb/setup

+ 1
- 1
Dockerfile View File

5
 COPY files /
5
 COPY files /
6
 
6
 
7
 RUN apk update && \
7
 RUN apk update && \
8
-    apk add --no-cache mariadb mariadb-server-utils  mariadb-client nginx pwgen su-exec python3 openssl && \
8
+    apk add --no-cache mariadb mariadb-server-utils mariadb-client nginx pwgen su-exec python3 openssl && \
9
     pip3 install acme-tiny
9
     pip3 install acme-tiny

+ 9
- 0
files/etc/s6/mariadb-upgrade/run View File

1
+#!/bin/sh
2
+
3
+s6-svwait -ua /etc/s6/mariadb
4
+sleep 2
5
+
6
+echo "triggering MariaDB upgrade..."
7
+mysql_upgrade
8
+
9
+exec tail -f /dev/null

+ 3
- 20
files/etc/s6/mariadb/setup View File

4
   echo "/run/mysqld not found so creating one"
4
   echo "/run/mysqld not found so creating one"
5
   mkdir -p /run/mysqld
5
   mkdir -p /run/mysqld
6
 fi
6
 fi
7
+echo "ensuring /run/mysqld permissions"
7
 chown mysql:mysql /run/mysqld
8
 chown mysql:mysql /run/mysqld
8
 
9
 
9
 if [ /etc/my.cnf.d/mariadb-server.cnf ]; then
10
 if [ /etc/my.cnf.d/mariadb-server.cnf ]; then
30
     if echo 'SELECT 1' | mysql &> /dev/null; then
31
     if echo 'SELECT 1' | mysql &> /dev/null; then
31
       break
32
       break
32
     fi
33
     fi
33
-    echo 'MySQL init process in progress...'
34
+    echo 'MariaDB init process in progress...'
34
     sleep 5
35
     sleep 5
35
 	done
36
 	done
36
 
37
 
38
   cat /tmp/dbinit.sql | mysql
39
   cat /tmp/dbinit.sql | mysql
39
 
40
 
40
   if ! kill -s TERM "$pid" || ! wait "$pid"; then
41
   if ! kill -s TERM "$pid" || ! wait "$pid"; then
41
-    echo >&2 'MySQL init process failed.'
42
+    echo >&2 'MariaDB init process failed.'
42
     exit 1
43
     exit 1
43
   fi
44
   fi
44
 
45
 
45
   rm /tmp/dbinit.sql
46
   rm /tmp/dbinit.sql
46
 fi
47
 fi
47
-
48
-su-exec mysql:mysql mysqld --bind-address=127.0.0.1 --datadir=$DATADIR &
49
-pid="$!"
50
-
51
-for i in {30..0}; do
52
-  if echo 'SELECT 1' | mysql &> /dev/null; then
53
-    break
54
-  fi
55
-  echo 'MySQL init process in progress...'
56
-  sleep 5
57
-done
58
-
59
-mysql_upgrade
60
-
61
-if ! kill -s TERM "$pid" || ! wait "$pid"; then
62
-  echo >&2 'MySQL upgrade process failed.'
63
-  exit 1
64
-fi

Loading…
Cancel
Save