From 500e8a9d1562cb1d456460ac09545f0585055dbf Mon Sep 17 00:00:00 2001 From: Shuai Lin Date: Mon, 21 Nov 2016 11:25:56 +0800 Subject: [PATCH] Use server.letsencrypt instead of server.https --- image/base/my_init.d/99_mysql_setup.sh | 12 +++++++++--- image/base/services/mysql.sh | 2 +- samples/server-https.conf | 2 +- scripts/bootstrap.py | 2 +- templates/Dockerfile.template | 3 +-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/image/base/my_init.d/99_mysql_setup.sh b/image/base/my_init.d/99_mysql_setup.sh index aef7703..35bacb3 100755 --- a/image/base/my_init.d/99_mysql_setup.sh +++ b/image/base/my_init.d/99_mysql_setup.sh @@ -14,11 +14,11 @@ if [[ ! -d /var/lib/mysql/mysql ]]; then rm -rf /var/run/mysqld/* echo 'Starting mysqld' - # The sleep 1 is there to make sure that inotifywait starts up before the socket is created - mysqld_safe >>/var/log/bootstrap-mysql.log & + mysqld_safe >>/var/log/mysql-bootstrap.log 2>&1 & echo 'Waiting for mysqld to come online' - while [[ ! -x /var/run/mysqld/mysqld.sock ]]; do + # The sleep 1 is there to make sure that inotifywait starts up before the socket is created + while [[ ! -S /var/run/mysqld/mysqld.sock ]]; do sleep 1 done @@ -38,4 +38,10 @@ if [[ ! -d /var/lib/mysql/mysql ]]; then echo 'Shutting down mysqld' mysqladmin -uroot shutdown + + retry=0 maxretry=10 + while [[ -e /var/run/mysqld/mysqld.sock && $retry -le $maxretry ]]; do + retry=$((retry+1)) + sleep 1 + done fi diff --git a/image/base/services/mysql.sh b/image/base/services/mysql.sh index 984e682..4b24039 100755 --- a/image/base/services/mysql.sh +++ b/image/base/services/mysql.sh @@ -3,7 +3,7 @@ set -e shutdown_mysql() { - if [[ -d /var/run/mysqld/mysqld.sock ]]; then + if [[ -S /var/run/mysqld/mysqld.sock ]]; then mysqladmin -u root shutdown || true fi } diff --git a/samples/server-https.conf b/samples/server-https.conf index e64be3d..92b1fe3 100644 --- a/samples/server-https.conf +++ b/samples/server-https.conf @@ -1,7 +1,7 @@ # If you edit this file, remember to run ./launcher rebuild [server] server.hostname = seafile.example.com -server.https = true +server.letsencrypt = true admin.email = me@example.com admin.password = asecret server.port_mappings = 80:80,443:443 \ No newline at end of file diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 15539cf..e2e6845 100755 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -70,7 +70,7 @@ def init_letsencrypt(): ) def is_https(): - return get_conf('server.https', '').lower() == 'true' + return get_conf('server.letsencrypt', '').lower() == 'true' def generate_local_dockerfile(): show_progress('Generating local Dockerfile ...') diff --git a/templates/Dockerfile.template b/templates/Dockerfile.template index 1f3d6ef..7f1578e 100644 --- a/templates/Dockerfile.template +++ b/templates/Dockerfile.template @@ -10,9 +10,8 @@ ADD bootstrap /bootstrap ADD scripts/tmp/check_init_admin.py /opt/seafile/seafile-server-{{ seafile_version }}/check_init_admin.py {%- endif %} -ADD bootstrap/generated/seafile.nginx.conf /etc/nginx/sites-enabled/seafile.nginx.conf - {%- if https %} +ADD bootstrap/generated/seafile.nginx.conf /etc/nginx/sites-enabled/seafile.nginx.conf ADD bootstrap/generated/letsencrypt.cron /etc/cron.d/letsencrypt.cron {%- endif %}