From fbed61ca37dcaf91e7915c737d54de6b3f717663 Mon Sep 17 00:00:00 2001 From: cuihaikuo Date: Tue, 19 Nov 2019 03:43:52 +0100 Subject: [PATCH] mv seafile/logs to /shared/seafile/logs and persistence nginx's config file. --- image/Makefile | 2 +- image/pro_seafile/Dockerfile | 2 +- scripts/bootstrap.py | 21 +++++++++++++-------- scripts/create_data_links.sh | 17 ++++++++++++----- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/image/Makefile b/image/Makefile index a25309d..a9d848c 100644 --- a/image/Makefile +++ b/image/Makefile @@ -1,4 +1,4 @@ -server_version=7.0.9 +server_version=7.0.11 base_image=seafileltd/base-mc:18.04 base_image_squashed=seafileltd/base-mc:18.04-squashed diff --git a/image/pro_seafile/Dockerfile b/image/pro_seafile/Dockerfile index a2f77ee..b32fb6c 100644 --- a/image/pro_seafile/Dockerfile +++ b/image/pro_seafile/Dockerfile @@ -1,7 +1,7 @@ FROM seafileltd/pro-base-mc:18.04 WORKDIR /opt/seafile -ENV SEAFILE_VERSION=7.0.9 SEAFILE_SERVER=seafile-pro-server +ENV SEAFILE_VERSION=7.0.11 SEAFILE_SERVER=seafile-pro-server RUN mkdir -p /etc/my_init.d diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 5e73d6f..7bfeda3 100755 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -61,8 +61,9 @@ def init_letsencrypt(): 'https': False, 'domain': domain, } - render_template('/templates/seafile.nginx.conf.template', - '/etc/nginx/sites-enabled/seafile.nginx.conf', context) + if not os.path.isfile('/shared/nginx/conf/seafile.nginx.conf'): + render_template('/templates/seafile.nginx.conf.template', + '/etc/nginx/sites-enabled/seafile.nginx.conf', context) call('nginx -s reload') time.sleep(2) @@ -84,12 +85,16 @@ def generate_local_nginx_conf(): 'https': is_https(), 'domain': domain, } - render_template( - '/templates/seafile.nginx.conf.template', - '/etc/nginx/sites-enabled/seafile.nginx.conf', - context - ) + if not os.path.isfile('/shared/nginx/conf/seafile.nginx.conf'): + render_template( + '/templates/seafile.nginx.conf.template', + '/etc/nginx/sites-enabled/seafile.nginx.conf', + context + ) + nginx_etc_file = '/etc/nginx/sites-enabled/seafile.nginx.conf' + nginx_shared_file = '/shared/nginx/conf/seafile.nginx.conf' + call('mv {0} {1} && ln -sf {1} {0}'.format(nginx_etc_file, nginx_shared_file)) def is_https(): return get_conf('SEAFILE_SERVER_LETSENCRYPT', 'false').lower() == 'true' @@ -189,7 +194,7 @@ COMPRESS_CACHE_BACKEND = 'locmem'""") # container, we need to move them to the shared volume # # e.g move "/opt/seafile/seafile-data" to "/shared/seafile/seafile-data" - files_to_copy = ['conf', 'ccnet', 'seafile-data', 'seahub-data', 'pro-data'] + files_to_copy = ['conf', 'ccnet', 'seafile-data', 'seahub-data', 'pro-data', 'logs'] for fn in files_to_copy: src = join(topdir, fn) dst = join(shared_seafiledir, fn) diff --git a/scripts/create_data_links.sh b/scripts/create_data_links.sh index cdecc3c..8c6d5a4 100755 --- a/scripts/create_data_links.sh +++ b/scripts/create_data_links.sh @@ -18,12 +18,17 @@ if [[ $TIME_ZONE != "" ]]; then fi fi +if [[ -e /shared/logs/seafile ]]; then + mv /shared/logs/seafile /shared/seafile/logs +fi + dirs=( conf ccnet seafile-data seahub-data pro-data + logs seafile-license.txt ) @@ -34,12 +39,14 @@ for d in ${dirs[*]}; do fi done -if [[ ! -e /shared/logs/seafile ]]; then - mkdir -p /shared/logs/seafile -fi -rm -rf /opt/seafile/logs && ln -sf /shared/logs/seafile/ /opt/seafile/logs - if [[ ! -e /shared/logs/var-log ]]; then mv /var/log /shared/logs/var-log fi rm -rf /var/log && ln -sf /shared/logs/var-log /var/log + +mkdir -p /shared/nginx/conf/ + +if [[ -e /shared/nginx/conf/seafile.nginx.conf ]]; then + rm -rf /etc/nginx/sites-enabled/seafile.nginx.conf && \ + ln -sf /shared/nginx/conf/seafile.nginx.conf /etc/nginx/sites-enabled +fi