From 2b228c3484edc45c7593c338ac5d42b417ad183e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:32:25 +0200 Subject: [PATCH 01/44] Add a script to build image for cron and supervisord --- utils/publish/feature--cron-or-supervisord.sh | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 utils/publish/feature--cron-or-supervisord.sh diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh new file mode 100755 index 0000000..71806be --- /dev/null +++ b/utils/publish/feature--cron-or-supervisord.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Restrict to pipeline triggered by pushes. +if [ $CI_PIPELINE_SOURCE != "push" ]; then + echo "This must be only ran from pushes." + exit 1 +fi + +# Login with Docker Registry. +echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin + +# Build and push as staging. +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord Dockerfile.supervisord +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron Dockerfile.cron +docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord +docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron \ No newline at end of file From e7daeeaec112231f40176cfcaa8a29dc29a8331a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:32:41 +0200 Subject: [PATCH 02/44] Add the CI stage to build for cron and supervisord --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09d9c34..d9f9960 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,13 @@ stages: before_script: - apk add bash +cron_or_supervisord: + stage: build_publish + script: + - /bin/bash utils/publish/feature--cron-or-supervisord.sh + only: + - feature--cron-or-supervisord + staging: stage: build_publish script: From c8c575dfa192c9cb66f0aedf8a3812adb93f7200 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:55:22 +0200 Subject: [PATCH 03/44] Remove the debugging, use absolute paths --- assets/infinite-seaf-cli-start.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/assets/infinite-seaf-cli-start.sh b/assets/infinite-seaf-cli-start.sh index dc7abb6..5aadbcf 100755 --- a/assets/infinite-seaf-cli-start.sh +++ b/assets/infinite-seaf-cli-start.sh @@ -16,11 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -x - -sleep 10 +/bin/sleep 10 while true; do /usr/bin/seaf-cli stop /usr/bin/seaf-cli start - sleep 1200 + /bin/sleep 1200 done \ No newline at end of file From 7ca5f507271285171a7a4b27bb170e70d5efd61e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:55:53 +0200 Subject: [PATCH 04/44] Rename with supervisord --- .../{seafile-entrypoint.sh => seafile-supervisord-entrypoint.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/{seafile-entrypoint.sh => seafile-supervisord-entrypoint.sh} (100%) diff --git a/assets/seafile-entrypoint.sh b/assets/seafile-supervisord-entrypoint.sh similarity index 100% rename from assets/seafile-entrypoint.sh rename to assets/seafile-supervisord-entrypoint.sh From fe5f07f20a7f9399ae9bb8fa3a4fb3466c8cd33c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:56:05 +0200 Subject: [PATCH 05/44] Rename with supervisord --- Dockerfile => Dockerfile.supervisord | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename Dockerfile => Dockerfile.supervisord (93%) diff --git a/Dockerfile b/Dockerfile.supervisord similarity index 93% rename from Dockerfile rename to Dockerfile.supervisord index 56d653f..1f4254d 100644 --- a/Dockerfile +++ b/Dockerfile.supervisord @@ -19,12 +19,10 @@ FROM debian:jessie-slim # Prevent the packages installation to halt. ENV DEBIAN_FRONTEND noninteractive -# Copy over the seafile repository. -COPY assets/seafile.list /etc/apt/sources.list.d/ - # Safely import Seafile APT key, then install both seafile-cli and supervisord. COPY utils/build/import-seafile-apt-key.sh / -RUN /bin/bash /import-seafile-apt-key.sh ;\ +RUN echo "deb http://deb.seadrive.org jessie main" > /etc/apt/source.list.d/seafile.list ;\ + /bin/bash /import-seafile-apt-key.sh ;\ apt-get update ;\ apt-get install \ -o Dpkg::Options::="--force-confold" \ From f4247ef87595ea67e44c36a621c66cde8e6b7576 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:56:44 +0200 Subject: [PATCH 06/44] Update paths to the Seafile entrypoint --- assets/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/docker-entrypoint.sh b/assets/docker-entrypoint.sh index 23906f8..63f6082 100644 --- a/assets/docker-entrypoint.sh +++ b/assets/docker-entrypoint.sh @@ -41,7 +41,7 @@ fi # Set the files ownership. chown $UID.$GID -R /home/seafuser/supervisord.conf chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh -chown $UID.$GID -R /home/seafuser/entrypoint.sh +chown $UID.$GID -R /home/seafuser/seafile-entrypoint.sh chown $UID.$GID -R /volume # Run the Seafile client as the container user. @@ -51,5 +51,5 @@ su - $UNAME << EO export SEAF_PASSWORD=$SEAF_PASSWORD export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME - /bin/bash /home/seafuser/entrypoint.sh + /bin/bash /home/seafuser/seafile-entrypoint.sh EO \ No newline at end of file From 9e76014bc355afd27127f53de607f3bbd1e40ace Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:56:54 +0200 Subject: [PATCH 07/44] Add a Dockerfile for cron --- Dockerfile.cron | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Dockerfile.cron diff --git a/Dockerfile.cron b/Dockerfile.cron new file mode 100644 index 0000000..cb4433c --- /dev/null +++ b/Dockerfile.cron @@ -0,0 +1,57 @@ +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +FROM debian:jessie-slim + +# Prevent the packages installation to halt. +ENV DEBIAN_FRONTEND noninteractive + +# Copy over the Docker related files. +COPY utils/build/import-seafile-apt-key.sh assets/docker-entrypoint.sh / + +# Copy over the required files for Seafile/SupervisorD. +COPY assets/infinite-seaf-cli-start.sh assets/seafile-entrypoint.sh /home/seafuser/ + +# Safely import Seafile APT key, then install both seafile-cli and supervisord. +RUN echo "deb http://deb.seadrive.org jessie main" \ > /etc/apt/source.list.d/seafile.list ;\ + bash /import-seafile-apt-key.sh ;\ + apt-get update ;\ + apt-get install \ + -o Dpkg::Options::="--force-confold" \ + -y \ + seafile-cli \ + cron ;\ + apt-get clean ;\ + apt-get autoclean \ + -o APT::Clean-Installed=true ;\ + rm \ + -f \ + /var/log/fsck/*.log \ + /var/log/apt/*.log \ + /var/cache/debconf/*.dat-old \ + /import-seafile-apt-key.sh ;\ + mkdir /volume/ ;\ + echo "seafuser" > /etc/cron.allow ;\ + echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" > /var/spool/cron/crontabs/seafuser + +# Create the seafile client user. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 +RUN groupadd -g $GID -o $UNAME ;\ + useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME + +ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] From 6b57dd606b1ffc79fcd2aa8f51afbcaa9f997da0 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 17:57:04 +0200 Subject: [PATCH 08/44] Add a Seafile entrypoint for cron --- assets/seafile-cron-entrypoint.sh | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 assets/seafile-cron-entrypoint.sh diff --git a/assets/seafile-cron-entrypoint.sh b/assets/seafile-cron-entrypoint.sh new file mode 100644 index 0000000..5eda987 --- /dev/null +++ b/assets/seafile-cron-entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Define variable shortcuts for readability purposes. +seafile_ini=~/.ccnet/seafile.ini +seafile_sock=~/.seafile/seafile-data/seafile.sock + +# Prepare the directories. +mkdir ~/.seafile +mkdir ~/.supervisord + +# Safely initialise the Seafile client. +/usr/bin/seaf-cli init -d ~/.seafile +while [ ! -f $seafile_ini ]; do sleep 1; done + +# Safely start the Seafile daemon. +/usr/bin/seaf-cli start +while [ ! -S $seafile_sock ]; do sleep 1; done + +# Start the synchronisation. +/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume + +# Start the supervisord. +/usr/sbin/cron -f \ No newline at end of file From 5382c5c6e1b32c5251b101060b5c12de0eedbe6c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 18:02:23 +0200 Subject: [PATCH 09/44] Revert back to not named entrypoints --- assets/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/docker-entrypoint.sh b/assets/docker-entrypoint.sh index 63f6082..23906f8 100644 --- a/assets/docker-entrypoint.sh +++ b/assets/docker-entrypoint.sh @@ -41,7 +41,7 @@ fi # Set the files ownership. chown $UID.$GID -R /home/seafuser/supervisord.conf chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh -chown $UID.$GID -R /home/seafuser/seafile-entrypoint.sh +chown $UID.$GID -R /home/seafuser/entrypoint.sh chown $UID.$GID -R /volume # Run the Seafile client as the container user. @@ -51,5 +51,5 @@ su - $UNAME << EO export SEAF_PASSWORD=$SEAF_PASSWORD export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME - /bin/bash /home/seafuser/seafile-entrypoint.sh + /bin/bash /home/seafuser/entrypoint.sh EO \ No newline at end of file From 5501553cb518f3337d3077ed98707a071d9b39e2 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 18:02:53 +0200 Subject: [PATCH 10/44] Reduce layers, revert back to not named entrypoints --- Dockerfile.cron | 29 ++++++++++++++++------------- Dockerfile.supervisord | 29 ++++++++++++++--------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index cb4433c..6371a76 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -18,15 +18,18 @@ FROM debian:jessie-slim # Prevent the packages installation to halt. ENV DEBIAN_FRONTEND noninteractive +# Create the seafile client user. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 # Copy over the Docker related files. -COPY utils/build/import-seafile-apt-key.sh assets/docker-entrypoint.sh / - -# Copy over the required files for Seafile/SupervisorD. -COPY assets/infinite-seaf-cli-start.sh assets/seafile-entrypoint.sh /home/seafuser/ +COPY utils/build/import-seafile-apt-key.sh / +COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -RUN echo "deb http://deb.seadrive.org jessie main" \ > /etc/apt/source.list.d/seafile.list ;\ +RUN echo "deb http://deb.seadrive.org jessie main" \ + > /etc/apt/source.list.d/seafile.list ;\ bash /import-seafile-apt-key.sh ;\ apt-get update ;\ apt-get install \ @@ -45,13 +48,13 @@ RUN echo "deb http://deb.seadrive.org jessie main" \ > /etc/apt/source.list.d/se /import-seafile-apt-key.sh ;\ mkdir /volume/ ;\ echo "seafuser" > /etc/cron.allow ;\ - echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" > /var/spool/cron/crontabs/seafuser - -# Create the seafile client user. -ENV UNAME=seafuser -ENV UID=1000 -ENV GID=1000 -RUN groupadd -g $GID -o $UNAME ;\ + echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" \ + > /var/spool/cron/crontabs/seafuser \; + groupadd -g $GID -o $UNAME ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME -ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] +# Copy over the required files for Seafile/SupervisorD. +COPY assets/infinite-seaf-cli-start.sh /home/seafuser/ +COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh + +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/Dockerfile.supervisord b/Dockerfile.supervisord index 1f4254d..0075026 100644 --- a/Dockerfile.supervisord +++ b/Dockerfile.supervisord @@ -18,10 +18,18 @@ FROM debian:jessie-slim # Prevent the packages installation to halt. ENV DEBIAN_FRONTEND noninteractive +# Specify the user running Seafile. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 + +# Copy over the Docker related files. +COPY utils/build/import-seafile-apt-key.sh / +COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -COPY utils/build/import-seafile-apt-key.sh / -RUN echo "deb http://deb.seadrive.org jessie main" > /etc/apt/source.list.d/seafile.list ;\ +RUN echo "deb http://deb.seadrive.org jessie main" \ + > /etc/apt/source.list.d/seafile.list ;\ /bin/bash /import-seafile-apt-key.sh ;\ apt-get update ;\ apt-get install \ @@ -37,22 +45,13 @@ RUN echo "deb http://deb.seadrive.org jessie main" > /etc/apt/source.list.d/seaf /var/log/fsck/*.log \ /var/log/apt/*.log \ /var/cache/debconf/*.dat-old \ - /import-seafile-apt-key.sh - -# Create the seafile client user. -ENV UNAME=seafuser -ENV UID=1000 -ENV GID=1000 -RUN groupadd -g $GID -o $UNAME ;\ + /import-seafile-apt-key.sh ;\ + mkdir /volume ;\ + groupadd -g $GID -o $UNAME ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME -# Copy over the Docker entrypoint. -COPY assets/docker-entrypoint.sh /entrypoint.sh - # Copy over the required files for Seafile/SupervisorD. -COPY assets/supervisord.conf /home/seafuser/ -COPY assets/infinite-seaf-cli-start.sh /home/seafuser/ +COPY assets/supervisord.conf assets/infinite-seaf-cli-start.sh /home/seafuser/ COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh -RUN mkdir /volume ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] From 2b9c85c65de03bdcce5e907963cda1b5ba877107 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 18:05:40 +0200 Subject: [PATCH 11/44] Fix docker build parameter when using named files --- utils/publish/feature--cron-or-supervisord.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh index 71806be..7fd2670 100755 --- a/utils/publish/feature--cron-or-supervisord.sh +++ b/utils/publish/feature--cron-or-supervisord.sh @@ -26,7 +26,7 @@ fi echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin # Build and push as staging. -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord Dockerfile.supervisord -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron Dockerfile.cron +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f Dockerfile.supervisord +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f Dockerfile.cron docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron \ No newline at end of file From d56cb13d7f84261afcec806233cdd3bbca04079e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 18:07:57 +0200 Subject: [PATCH 12/44] Build with the current path helps --- utils/publish/feature--cron-or-supervisord.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh index 7fd2670..7785594 100755 --- a/utils/publish/feature--cron-or-supervisord.sh +++ b/utils/publish/feature--cron-or-supervisord.sh @@ -26,7 +26,7 @@ fi echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin # Build and push as staging. -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f Dockerfile.supervisord -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f Dockerfile.cron +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f Dockerfile.supervisord . +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f Dockerfile.cron . docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron \ No newline at end of file From 9cfbe0d1298b686a1b61990e95da6e866f375146 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 18:14:07 +0200 Subject: [PATCH 13/44] Create the missing apt source.list.d directory --- Dockerfile.cron | 3 ++- Dockerfile.supervisord | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index 6371a76..2713a36 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -28,7 +28,8 @@ COPY utils/build/import-seafile-apt-key.sh / COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -RUN echo "deb http://deb.seadrive.org jessie main" \ +RUN mkdir -p /etc/apt/source.list.d/ ;\ + echo "deb http://deb.seadrive.org jessie main" \ > /etc/apt/source.list.d/seafile.list ;\ bash /import-seafile-apt-key.sh ;\ apt-get update ;\ diff --git a/Dockerfile.supervisord b/Dockerfile.supervisord index 0075026..c13b15c 100644 --- a/Dockerfile.supervisord +++ b/Dockerfile.supervisord @@ -28,7 +28,8 @@ COPY utils/build/import-seafile-apt-key.sh / COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -RUN echo "deb http://deb.seadrive.org jessie main" \ +RUN mkdir -p /etc/apt/source.list.d/ ;\ + echo "deb http://deb.seadrive.org jessie main" \ > /etc/apt/source.list.d/seafile.list ;\ /bin/bash /import-seafile-apt-key.sh ;\ apt-get update ;\ From 16f58875224dbeb5de659843e969809c07759738 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 23:10:41 +0200 Subject: [PATCH 14/44] Add the missing 's' to sources.list.d --- Dockerfile.cron | 4 ++-- Dockerfile.supervisord | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index 2713a36..7723c31 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -28,9 +28,9 @@ COPY utils/build/import-seafile-apt-key.sh / COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -RUN mkdir -p /etc/apt/source.list.d/ ;\ +RUN mkdir -p /etc/apt/sources.list.d/ ;\ echo "deb http://deb.seadrive.org jessie main" \ - > /etc/apt/source.list.d/seafile.list ;\ + > /etc/apt/sources.list.d/seafile.list ;\ bash /import-seafile-apt-key.sh ;\ apt-get update ;\ apt-get install \ diff --git a/Dockerfile.supervisord b/Dockerfile.supervisord index c13b15c..33a8d32 100644 --- a/Dockerfile.supervisord +++ b/Dockerfile.supervisord @@ -28,9 +28,9 @@ COPY utils/build/import-seafile-apt-key.sh / COPY assets/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. -RUN mkdir -p /etc/apt/source.list.d/ ;\ +RUN mkdir -p /etc/apt/sources.list.d/ ;\ echo "deb http://deb.seadrive.org jessie main" \ - > /etc/apt/source.list.d/seafile.list ;\ + > /etc/apt/sources.list.d/seafile.list ;\ /bin/bash /import-seafile-apt-key.sh ;\ apt-get update ;\ apt-get install \ From 511d18c4ae79aaac5bbb6ceebb5210cef9623bbf Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 23:16:19 +0200 Subject: [PATCH 15/44] Fix the path to cron/supervisord specific entrypoints --- Dockerfile.cron | 2 +- Dockerfile.supervisord | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index 7723c31..b808306 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -56,6 +56,6 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ # Copy over the required files for Seafile/SupervisorD. COPY assets/infinite-seaf-cli-start.sh /home/seafuser/ -COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh +COPY assets/seafile-cron-entrypoint.sh /home/seafuser/entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/Dockerfile.supervisord b/Dockerfile.supervisord index 33a8d32..acbcf5c 100644 --- a/Dockerfile.supervisord +++ b/Dockerfile.supervisord @@ -53,6 +53,6 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ # Copy over the required files for Seafile/SupervisorD. COPY assets/supervisord.conf assets/infinite-seaf-cli-start.sh /home/seafuser/ -COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh +COPY assets/seafile-supervisord-entrypoint.sh /home/seafuser/entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] From 2fc76dbf8be7922f4d7520e7352ff7c2eacf33cb Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 18 Apr 2019 23:21:50 +0200 Subject: [PATCH 16/44] Fix the inverted line/command break --- Dockerfile.cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index b808306..1a7a31e 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -50,7 +50,7 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ mkdir /volume/ ;\ echo "seafuser" > /etc/cron.allow ;\ echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" \ - > /var/spool/cron/crontabs/seafuser \; + > /var/spool/cron/crontabs/seafuser ;\ groupadd -g $GID -o $UNAME ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME From 19281a3883d3931ca331c8f7f917a1af041d4d41 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 23 Apr 2019 20:29:31 +0200 Subject: [PATCH 17/44] Rename into a supervisord specific docker entrypoint --- assets/{docker-entrypoint.sh => docker-supervisord-entrypoint.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/{docker-entrypoint.sh => docker-supervisord-entrypoint.sh} (100%) diff --git a/assets/docker-entrypoint.sh b/assets/docker-supervisord-entrypoint.sh similarity index 100% rename from assets/docker-entrypoint.sh rename to assets/docker-supervisord-entrypoint.sh From 82f52e36df817fa3b62d852842d5e583185538ec Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 23 Apr 2019 20:29:42 +0200 Subject: [PATCH 18/44] A a cron specific docker entrypoint --- assets/docker-cron-entrypoint.sh | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 assets/docker-cron-entrypoint.sh diff --git a/assets/docker-cron-entrypoint.sh b/assets/docker-cron-entrypoint.sh new file mode 100644 index 0000000..c446e0f --- /dev/null +++ b/assets/docker-cron-entrypoint.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check mandatory Seafile configuration have been properly set. +if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi + +# Update the user ID, if the $UID changed. +if [ "$UID" != "1000" ]; then + usermod -u $UID $UNAME + # What if the $UID already exists ? +fi + +# Change the group, if the $GID changed. +if [ "$GID" != "1000" ]; then + getent group | grep ":$GID:" >/dev/null + if [ $? -eq 0 ]; then + usermod -g $GID -G 1000 $UNAME + else + groupmod -g $GID $UNAME + fi +fi + +# Set the files ownership. +chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh +chown $UID.$GID -R /home/seafuser/entrypoint.sh +chown $UID.$GID -R /volume + +# Run the Seafile client as the container user. +su - $UNAME << EO + export SEAF_SERVER_URL=$SEAF_SERVER_URL + export SEAF_USERNAME=$SEAF_USERNAME + export SEAF_PASSWORD=$SEAF_PASSWORD + export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID + export UNAME=$UNAME + /bin/bash /home/seafuser/entrypoint.sh +EO \ No newline at end of file From 1a44140556cabf2506833af844e0816cbd51baca Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:06:53 +0200 Subject: [PATCH 19/44] Rename infinite-seaf-cli-start.sh into seafile-healthcheck.sh --- Dockerfile | 2 +- assets/{infinite-seaf-cli-start.sh => seafile-healthcheck.sh} | 0 assets/supervisord.conf | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename assets/{infinite-seaf-cli-start.sh => seafile-healthcheck.sh} (100%) diff --git a/Dockerfile b/Dockerfile index 56d653f..9f3e528 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ COPY assets/docker-entrypoint.sh /entrypoint.sh # Copy over the required files for Seafile/SupervisorD. COPY assets/supervisord.conf /home/seafuser/ -COPY assets/infinite-seaf-cli-start.sh /home/seafuser/ +COPY assets/seaf-healthcheck.sh /home/seafuser/ COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh RUN mkdir /volume diff --git a/assets/infinite-seaf-cli-start.sh b/assets/seafile-healthcheck.sh similarity index 100% rename from assets/infinite-seaf-cli-start.sh rename to assets/seafile-healthcheck.sh diff --git a/assets/supervisord.conf b/assets/supervisord.conf index 560c374..c5425ee 100644 --- a/assets/supervisord.conf +++ b/assets/supervisord.conf @@ -24,7 +24,7 @@ file=~/.seafile/seafile-data/seafile.sock # Manage the infinite `seaf-cli start`. [program:seaf-cli-start-loop] -command=/bin/bash /home/seafuser/infinite-seaf-cli-start.sh +command=/bin/bash /home/seafuser/seaf-healthcheck.sh process_name=%(program_name)s numprocs=1 autostart=true From 33a93d7bc200395c4001a138a8d8b206f5980b60 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:07:41 +0200 Subject: [PATCH 20/44] Improve with support for libraries status that prevent restarts --- assets/seafile-healthcheck.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/assets/seafile-healthcheck.sh b/assets/seafile-healthcheck.sh index dc7abb6..16f60d4 100755 --- a/assets/seafile-healthcheck.sh +++ b/assets/seafile-healthcheck.sh @@ -16,11 +16,32 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -x +# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines. +# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing". +# +# This script grabs the output while ignoring the comments to iterate over the informations set to their columns, +# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't. -sleep 10 +seaf=/usr/bin/seaf-cli +dont_restart_on=("downloading" "committing" "waiting for sync") +restart=true + +sleep 10s while true; do - /usr/bin/seaf-cli stop - /usr/bin/seaf-cli start - sleep 1200 + while IFS=$'\t' read -r name status progress; do + if [ $status ]; then + for dont_restart_on_status in "${dont_restart_on[@]}"; do + if [ "$status" == "$dont_restart_on_status" ]; then + restart=false; break; break + fi + done + fi + done < <($seaf status | grep -v "^#") + + if $restart; then + $seaf stop + $seaf start + fi + + sleep 10m done \ No newline at end of file From 215db335a66a16f4ee1346e8aba1d549f4359e69 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:26:22 +0200 Subject: [PATCH 21/44] Use the proper Docker entrypoint --- Dockerfile.cron | 2 +- Dockerfile.supervisord | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index 1a7a31e..3cd88ab 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -25,7 +25,7 @@ ENV GID=1000 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / -COPY assets/docker-entrypoint.sh /entrypoint.sh +COPY assets/docker-cron-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. RUN mkdir -p /etc/apt/sources.list.d/ ;\ diff --git a/Dockerfile.supervisord b/Dockerfile.supervisord index acbcf5c..81dd58e 100644 --- a/Dockerfile.supervisord +++ b/Dockerfile.supervisord @@ -25,7 +25,7 @@ ENV GID=1000 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / -COPY assets/docker-entrypoint.sh /entrypoint.sh +COPY assets/docker-supervisord-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. RUN mkdir -p /etc/apt/sources.list.d/ ;\ From 3e1e7f7b718825a8d97f51341bcca172632382ea Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:27:21 +0200 Subject: [PATCH 22/44] Add a Docker image that just run a Bash sub process to keep it alive --- Dockerfile.bash | 56 +++++++++++++++++++++++++++++++ assets/docker-bash-entrypoint.sh | 54 +++++++++++++++++++++++++++++ assets/seafile-bash-entrypoint.sh | 38 +++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 Dockerfile.bash create mode 100644 assets/docker-bash-entrypoint.sh create mode 100644 assets/seafile-bash-entrypoint.sh diff --git a/Dockerfile.bash b/Dockerfile.bash new file mode 100644 index 0000000..401cde5 --- /dev/null +++ b/Dockerfile.bash @@ -0,0 +1,56 @@ +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +FROM debian:jessie-slim + +# Prevent the packages installation to halt. +ENV DEBIAN_FRONTEND noninteractive +# Specify the user running Seafile. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 + +# Copy over the Docker related files. +COPY utils/build/import-seafile-apt-key.sh / +COPY assets/docker-bash-entrypoint.sh /entrypoint.sh + +# Safely import Seafile APT key, then install both seafile-cli and supervisord. +RUN mkdir -p /etc/apt/sources.list.d/ ;\ + echo "deb http://deb.seadrive.org jessie main" \ + > /etc/apt/sources.list.d/seafile.list ;\ + /bin/bash /import-seafile-apt-key.sh ;\ + apt-get update ;\ + apt-get install \ + -o Dpkg::Options::="--force-confold" \ + -y seafile-cli ;\ + apt-get clean ;\ + apt-get autoclean \ + -o APT::Clean-Installed=true ;\ + rm \ + -f \ + /var/log/fsck/*.log \ + /var/log/apt/*.log \ + /var/cache/debconf/*.dat-old \ + /import-seafile-apt-key.sh ;\ + mkdir /volume ;\ + groupadd -g $GID -o $UNAME ;\ + useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME + +# Copy over the required files for Seafile/SupervisorD. +COPY assets/supervisord.conf assets/infinite-seaf-cli-start.sh /home/seafuser/ +COPY assets/seafile-bash-entrypoint.sh /home/seafuser/entrypoint.sh + +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh new file mode 100644 index 0000000..c446e0f --- /dev/null +++ b/assets/docker-bash-entrypoint.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check mandatory Seafile configuration have been properly set. +if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi +if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi + +# Update the user ID, if the $UID changed. +if [ "$UID" != "1000" ]; then + usermod -u $UID $UNAME + # What if the $UID already exists ? +fi + +# Change the group, if the $GID changed. +if [ "$GID" != "1000" ]; then + getent group | grep ":$GID:" >/dev/null + if [ $? -eq 0 ]; then + usermod -g $GID -G 1000 $UNAME + else + groupmod -g $GID $UNAME + fi +fi + +# Set the files ownership. +chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh +chown $UID.$GID -R /home/seafuser/entrypoint.sh +chown $UID.$GID -R /volume + +# Run the Seafile client as the container user. +su - $UNAME << EO + export SEAF_SERVER_URL=$SEAF_SERVER_URL + export SEAF_USERNAME=$SEAF_USERNAME + export SEAF_PASSWORD=$SEAF_PASSWORD + export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID + export UNAME=$UNAME + /bin/bash /home/seafuser/entrypoint.sh +EO \ No newline at end of file diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh new file mode 100644 index 0000000..2ceae1a --- /dev/null +++ b/assets/seafile-bash-entrypoint.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Define variable shortcuts for readability purposes. +seafile_ini=~/.ccnet/seafile.ini +seafile_sock=~/.seafile/seafile-data/seafile.sock + +# Prepare the directories. +mkdir ~/.seafile + +# Safely initialise the Seafile client. +/usr/bin/seaf-cli init -d ~/.seafile +while [ ! -f $seafile_ini ]; do sleep 1; done + +# Safely start the Seafile daemon. +/usr/bin/seaf-cli start +while [ ! -S $seafile_sock ]; do sleep 1; done + +# Start the synchronisation. +/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume + +# Start the Seafile healthcheck as a disowned process. +(/usr/bin/bash ~/infinite-seaf-cli-start.sh &) \ No newline at end of file From 030111b90c80722c6761154a8e652a82513b4d43 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:27:32 +0200 Subject: [PATCH 23/44] Build the Docker bash image --- utils/publish/feature--cron-or-supervisord.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh index 7785594..26f8348 100755 --- a/utils/publish/feature--cron-or-supervisord.sh +++ b/utils/publish/feature--cron-or-supervisord.sh @@ -28,5 +28,7 @@ echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docke # Build and push as staging. docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f Dockerfile.supervisord . docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f Dockerfile.cron . +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-bash -f Dockerfile.bash . docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron \ No newline at end of file +docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron +docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-bash From 31acb88cdea00d3c03b60e22e08367426712973e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:56:16 +0200 Subject: [PATCH 24/44] Fix path to bash --- assets/seafile-bash-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index 2ceae1a..228754c 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -35,4 +35,4 @@ while [ ! -S $seafile_sock ]; do sleep 1; done /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume # Start the Seafile healthcheck as a disowned process. -(/usr/bin/bash ~/infinite-seaf-cli-start.sh &) \ No newline at end of file +(/bin/bash ~/infinite-seaf-cli-start.sh &) \ No newline at end of file From 280b42dc37a32df0238ad7db51578ac8b7698638 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:57:57 +0200 Subject: [PATCH 25/44] Create a pid file for cron --- Dockerfile.cron | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.cron b/Dockerfile.cron index 3cd88ab..3a5cbb0 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -51,6 +51,7 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ echo "seafuser" > /etc/cron.allow ;\ echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" \ > /var/spool/cron/crontabs/seafuser ;\ + touch /var/run/crond.pid ;\ groupadd -g $GID -o $UNAME ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME From 00cae794a0b03d97e5ff9ac35ab89469ebd9f9cb Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 11:58:15 +0200 Subject: [PATCH 26/44] Set ownership to the cron.pid file --- assets/docker-cron-entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/docker-cron-entrypoint.sh b/assets/docker-cron-entrypoint.sh index c446e0f..4136d61 100644 --- a/assets/docker-cron-entrypoint.sh +++ b/assets/docker-cron-entrypoint.sh @@ -39,9 +39,10 @@ if [ "$GID" != "1000" ]; then fi # Set the files ownership. -chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh -chown $UID.$GID -R /home/seafuser/entrypoint.sh -chown $UID.$GID -R /volume +chown $UID.$GID /var/run/crond.pid +chown $UID.$GID /home/seafuser/infinite-seaf-cli-start.sh +chown $UID.$GID /home/seafuser/entrypoint.sh +chown $UID.$GID -R /volume # Run the Seafile client as the container user. su - $UNAME << EO From 953b784e92278e4b1daf4b8407397c0e027f22f9 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 14:23:57 +0200 Subject: [PATCH 27/44] Replace Bash background process with nohup --- assets/seafile-bash-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index 228754c..d4851ec 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -35,4 +35,4 @@ while [ ! -S $seafile_sock ]; do sleep 1; done /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume # Start the Seafile healthcheck as a disowned process. -(/bin/bash ~/infinite-seaf-cli-start.sh &) \ No newline at end of file +nohup /bin/bash ~/infinite-seaf-cli-start.sh & \ No newline at end of file From ef1f52560cb5005221f259644ad292b90ffb89f3 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 14:40:25 +0200 Subject: [PATCH 28/44] Run cron as root --- Dockerfile.cron | 1 - assets/docker-bash-entrypoint.sh | 4 +++- assets/seafile-cron-entrypoint.sh | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile.cron b/Dockerfile.cron index 3a5cbb0..3cd88ab 100644 --- a/Dockerfile.cron +++ b/Dockerfile.cron @@ -51,7 +51,6 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ echo "seafuser" > /etc/cron.allow ;\ echo "*/20 * * * * /bin/bash /home/seafuser/infinite-seaf-cli-start.sh" \ > /var/spool/cron/crontabs/seafuser ;\ - touch /var/run/crond.pid ;\ groupadd -g $GID -o $UNAME ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh index c446e0f..43711a7 100644 --- a/assets/docker-bash-entrypoint.sh +++ b/assets/docker-bash-entrypoint.sh @@ -51,4 +51,6 @@ su - $UNAME << EO export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh -EO \ No newline at end of file +EO + +cron -f \ No newline at end of file diff --git a/assets/seafile-cron-entrypoint.sh b/assets/seafile-cron-entrypoint.sh index 5eda987..7716ba7 100644 --- a/assets/seafile-cron-entrypoint.sh +++ b/assets/seafile-cron-entrypoint.sh @@ -33,7 +33,4 @@ while [ ! -f $seafile_ini ]; do sleep 1; done while [ ! -S $seafile_sock ]; do sleep 1; done # Start the synchronisation. -/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume - -# Start the supervisord. -/usr/sbin/cron -f \ No newline at end of file +/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume \ No newline at end of file From b8eef1e1613c76f408768d348e75c77ef5a7c823 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 15:09:30 +0200 Subject: [PATCH 29/44] Use cron where it should be used --- assets/docker-bash-entrypoint.sh | 4 +--- assets/docker-cron-entrypoint.sh | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh index 43711a7..c446e0f 100644 --- a/assets/docker-bash-entrypoint.sh +++ b/assets/docker-bash-entrypoint.sh @@ -51,6 +51,4 @@ su - $UNAME << EO export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh -EO - -cron -f \ No newline at end of file +EO \ No newline at end of file diff --git a/assets/docker-cron-entrypoint.sh b/assets/docker-cron-entrypoint.sh index 4136d61..72b4189 100644 --- a/assets/docker-cron-entrypoint.sh +++ b/assets/docker-cron-entrypoint.sh @@ -52,4 +52,6 @@ su - $UNAME << EO export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh -EO \ No newline at end of file +EO + +cron -f \ No newline at end of file From 76c26f7356f5ad7d7e0cd7fd2ba938f44e083131 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 17:19:31 +0200 Subject: [PATCH 30/44] Remove the infinite seafile restart process --- assets/seafile-bash-entrypoint.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index d4851ec..c7e529b 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -33,6 +33,3 @@ while [ ! -S $seafile_sock ]; do sleep 1; done # Start the synchronisation. /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume - -# Start the Seafile healthcheck as a disowned process. -nohup /bin/bash ~/infinite-seaf-cli-start.sh & \ No newline at end of file From ab2c6dc1a7e9c39c16234ac7190f7881990acec2 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 17:19:49 +0200 Subject: [PATCH 31/44] Add the infinite seafile restart process --- assets/docker-bash-entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh index c446e0f..3883532 100644 --- a/assets/docker-bash-entrypoint.sh +++ b/assets/docker-bash-entrypoint.sh @@ -51,4 +51,6 @@ su - $UNAME << EO export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh -EO \ No newline at end of file +EO + +nohup /bin/bash ~/infinite-seaf-cli-start.sh & From 2f465ca270eba23c3ca0c043a0e7a3c68bd1b97e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 17:20:14 +0200 Subject: [PATCH 32/44] Dont change ownership to crond.pid --- assets/docker-cron-entrypoint.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/docker-cron-entrypoint.sh b/assets/docker-cron-entrypoint.sh index 72b4189..39ea374 100644 --- a/assets/docker-cron-entrypoint.sh +++ b/assets/docker-cron-entrypoint.sh @@ -39,7 +39,6 @@ if [ "$GID" != "1000" ]; then fi # Set the files ownership. -chown $UID.$GID /var/run/crond.pid chown $UID.$GID /home/seafuser/infinite-seaf-cli-start.sh chown $UID.$GID /home/seafuser/entrypoint.sh chown $UID.$GID -R /volume From ee0975a1aa369e9992e2075562294b975654675e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 18:36:26 +0200 Subject: [PATCH 33/44] Replace nohup with exec --- assets/docker-bash-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh index 3883532..9a6e098 100644 --- a/assets/docker-bash-entrypoint.sh +++ b/assets/docker-bash-entrypoint.sh @@ -53,4 +53,4 @@ su - $UNAME << EO /bin/bash /home/seafuser/entrypoint.sh EO -nohup /bin/bash ~/infinite-seaf-cli-start.sh & +exec /bin/bash ~/infinite-seaf-cli-start.sh & From 67f09f71b2f8849982a18c3c995e454cd1b40679 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Wed, 24 Apr 2019 20:54:21 +0200 Subject: [PATCH 34/44] Switch the infinite restart to the Seafile entrypoint --- assets/docker-bash-entrypoint.sh | 4 +--- assets/seafile-bash-entrypoint.sh | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/docker-bash-entrypoint.sh b/assets/docker-bash-entrypoint.sh index 9a6e098..c446e0f 100644 --- a/assets/docker-bash-entrypoint.sh +++ b/assets/docker-bash-entrypoint.sh @@ -51,6 +51,4 @@ su - $UNAME << EO export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh -EO - -exec /bin/bash ~/infinite-seaf-cli-start.sh & +EO \ No newline at end of file diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index c7e529b..fac55c9 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -33,3 +33,6 @@ while [ ! -S $seafile_sock ]; do sleep 1; done # Start the synchronisation. /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume + +# Run the infinite Seafile restart. +/bin/bash ~/infinite-seaf-cli-start.sh & From cf39d73cc552db84ed744a54886b29f0a64521c7 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 25 Apr 2019 07:51:18 +0200 Subject: [PATCH 35/44] Use source instead of exec --- assets/seafile-bash-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index fac55c9..5d9eb61 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -35,4 +35,4 @@ while [ ! -S $seafile_sock ]; do sleep 1; done /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume # Run the infinite Seafile restart. -/bin/bash ~/infinite-seaf-cli-start.sh & +source ~/infinite-seaf-cli-start.sh & From cf2b56d658af911af81a1f4a810be5678c9e456c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 25 Apr 2019 12:51:36 +0200 Subject: [PATCH 36/44] Remove ampersand to start in the background --- assets/seafile-bash-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/seafile-bash-entrypoint.sh b/assets/seafile-bash-entrypoint.sh index 5d9eb61..52aa07d 100644 --- a/assets/seafile-bash-entrypoint.sh +++ b/assets/seafile-bash-entrypoint.sh @@ -35,4 +35,4 @@ while [ ! -S $seafile_sock ]; do sleep 1; done /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume # Run the infinite Seafile restart. -source ~/infinite-seaf-cli-start.sh & +source ~/infinite-seaf-cli-start.sh From cbb2b84e774f6c0f32e5f238c0cca075f125a098 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 25 Apr 2019 15:41:33 +0200 Subject: [PATCH 37/44] Fix the healthcheck script path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9f3e528..856e45b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ COPY assets/docker-entrypoint.sh /entrypoint.sh # Copy over the required files for Seafile/SupervisorD. COPY assets/supervisord.conf /home/seafuser/ -COPY assets/seaf-healthcheck.sh /home/seafuser/ +COPY assets/seafile-healthcheck.sh /home/seafuser/ COPY assets/seafile-entrypoint.sh /home/seafuser/entrypoint.sh RUN mkdir /volume From 7b09e0fe66d41c7234ce6e6930379a19e2ee9872 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:39:02 +0200 Subject: [PATCH 38/44] Move cron/supervisord/bash alternatives into their own directories --- Dockerfile.bash => assets/bash/Dockerfile | 6 +-- .../docker-entrypoint.sh} | 0 .../seafile-entrypoint.sh} | 0 assets/{ => bash}/seafile-healthcheck.sh | 0 Dockerfile.cron => assets/cron/Dockerfile | 6 +-- .../docker-entrypoint.sh} | 0 .../seafile-entrypoint.sh} | 0 .../seafile-healthcheck.sh} | 0 .../supervisord/Dockerfile | 6 +-- .../docker-entrypoint.sh} | 0 .../seafile-entrypoint.sh} | 0 assets/supervisord/seafile-healthcheck.sh | 47 +++++++++++++++++++ assets/{ => supervisord}/supervisord.conf | 0 13 files changed, 56 insertions(+), 9 deletions(-) rename Dockerfile.bash => assets/bash/Dockerfile (91%) rename assets/{docker-bash-entrypoint.sh => bash/docker-entrypoint.sh} (100%) rename assets/{seafile-bash-entrypoint.sh => bash/seafile-entrypoint.sh} (100%) rename assets/{ => bash}/seafile-healthcheck.sh (100%) rename Dockerfile.cron => assets/cron/Dockerfile (92%) rename assets/{docker-cron-entrypoint.sh => cron/docker-entrypoint.sh} (100%) rename assets/{seafile-cron-entrypoint.sh => cron/seafile-entrypoint.sh} (100%) rename assets/{seafile-cron-healthcheck.sh => cron/seafile-healthcheck.sh} (100%) rename Dockerfile.supervisord => assets/supervisord/Dockerfile (89%) rename assets/{docker-supervisord-entrypoint.sh => supervisord/docker-entrypoint.sh} (100%) rename assets/{seafile-supervisord-entrypoint.sh => supervisord/seafile-entrypoint.sh} (100%) create mode 100755 assets/supervisord/seafile-healthcheck.sh rename assets/{ => supervisord}/supervisord.conf (100%) diff --git a/Dockerfile.bash b/assets/bash/Dockerfile similarity index 91% rename from Dockerfile.bash rename to assets/bash/Dockerfile index a6b37bb..81d93a6 100644 --- a/Dockerfile.bash +++ b/assets/bash/Dockerfile @@ -25,7 +25,7 @@ ENV GID=1000 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / -COPY assets/docker-bash-entrypoint.sh /entrypoint.sh +COPY assets/bash/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. RUN mkdir -p /etc/apt/sources.list.d/ ;\ @@ -50,7 +50,7 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME # Copy over the required files for Seafile/SupervisorD. -COPY assets/seafile-healthcheck.sh /home/seafuser/ -COPY assets/seafile-bash-entrypoint.sh /home/seafuser/entrypoint.sh +COPY assets/bash/seafile-healthcheck.sh /home/seafuser/ +COPY assets/bash/seafile-entrypoint.sh /home/seafuser/entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/assets/docker-bash-entrypoint.sh b/assets/bash/docker-entrypoint.sh similarity index 100% rename from assets/docker-bash-entrypoint.sh rename to assets/bash/docker-entrypoint.sh diff --git a/assets/seafile-bash-entrypoint.sh b/assets/bash/seafile-entrypoint.sh similarity index 100% rename from assets/seafile-bash-entrypoint.sh rename to assets/bash/seafile-entrypoint.sh diff --git a/assets/seafile-healthcheck.sh b/assets/bash/seafile-healthcheck.sh similarity index 100% rename from assets/seafile-healthcheck.sh rename to assets/bash/seafile-healthcheck.sh diff --git a/Dockerfile.cron b/assets/cron/Dockerfile similarity index 92% rename from Dockerfile.cron rename to assets/cron/Dockerfile index cbdff82..3272c7f 100644 --- a/Dockerfile.cron +++ b/assets/cron/Dockerfile @@ -25,7 +25,7 @@ ENV GID=1000 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / -COPY assets/docker-cron-entrypoint.sh /entrypoint.sh +COPY assets/cron/docker-entrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. RUN mkdir -p /etc/apt/sources.list.d/ ;\ @@ -55,7 +55,7 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME # Copy over the required files for Seafile/SupervisorD. -COPY assets/seafile-cron-healthcheck.sh /home/seafuser/seafile-healthcheck.sh -COPY assets/seafile-cron-entrypoint.sh /home/seafuser/entrypoint.sh +COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh +COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/assets/docker-cron-entrypoint.sh b/assets/cron/docker-entrypoint.sh similarity index 100% rename from assets/docker-cron-entrypoint.sh rename to assets/cron/docker-entrypoint.sh diff --git a/assets/seafile-cron-entrypoint.sh b/assets/cron/seafile-entrypoint.sh similarity index 100% rename from assets/seafile-cron-entrypoint.sh rename to assets/cron/seafile-entrypoint.sh diff --git a/assets/seafile-cron-healthcheck.sh b/assets/cron/seafile-healthcheck.sh similarity index 100% rename from assets/seafile-cron-healthcheck.sh rename to assets/cron/seafile-healthcheck.sh diff --git a/Dockerfile.supervisord b/assets/supervisord/Dockerfile similarity index 89% rename from Dockerfile.supervisord rename to assets/supervisord/Dockerfile index 1bafdb2..bf66fc7 100644 --- a/Dockerfile.supervisord +++ b/assets/supervisord/Dockerfile @@ -25,7 +25,7 @@ ENV GID=1000 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / -COPY assets/docker-supervisord-entrypoint.sh /entrypoint.sh +COPY assets/supervisord/dockerentrypoint.sh /entrypoint.sh # Safely import Seafile APT key, then install both seafile-cli and supervisord. RUN mkdir -p /etc/apt/sources.list.d/ ;\ @@ -52,7 +52,7 @@ RUN mkdir -p /etc/apt/sources.list.d/ ;\ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME # Copy over the required files for Seafile/SupervisorD. -COPY assets/supervisord.conf assets/seafile-healthcheck.sh /home/seafuser/ -COPY assets/seafile-supervisord-entrypoint.sh /home/seafuser/entrypoint.sh +COPY assets/supervisord/supervisord.conf assets/supervisord/seafile-healthcheck.sh /home/seafuser/ +COPY assets/supervisord/seafile-entrypoint.sh /home/seafuser/entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/assets/docker-supervisord-entrypoint.sh b/assets/supervisord/docker-entrypoint.sh similarity index 100% rename from assets/docker-supervisord-entrypoint.sh rename to assets/supervisord/docker-entrypoint.sh diff --git a/assets/seafile-supervisord-entrypoint.sh b/assets/supervisord/seafile-entrypoint.sh similarity index 100% rename from assets/seafile-supervisord-entrypoint.sh rename to assets/supervisord/seafile-entrypoint.sh diff --git a/assets/supervisord/seafile-healthcheck.sh b/assets/supervisord/seafile-healthcheck.sh new file mode 100755 index 0000000..16f60d4 --- /dev/null +++ b/assets/supervisord/seafile-healthcheck.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines. +# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing". +# +# This script grabs the output while ignoring the comments to iterate over the informations set to their columns, +# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't. + +seaf=/usr/bin/seaf-cli +dont_restart_on=("downloading" "committing" "waiting for sync") +restart=true + +sleep 10s +while true; do + while IFS=$'\t' read -r name status progress; do + if [ $status ]; then + for dont_restart_on_status in "${dont_restart_on[@]}"; do + if [ "$status" == "$dont_restart_on_status" ]; then + restart=false; break; break + fi + done + fi + done < <($seaf status | grep -v "^#") + + if $restart; then + $seaf stop + $seaf start + fi + + sleep 10m +done \ No newline at end of file diff --git a/assets/supervisord.conf b/assets/supervisord/supervisord.conf similarity index 100% rename from assets/supervisord.conf rename to assets/supervisord/supervisord.conf From 926b8836abe9282876e457ffadb736c48760cfb9 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:39:17 +0200 Subject: [PATCH 39/44] Update path to the alternative versions --- utils/publish/feature--cron-or-supervisord.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh index 26f8348..59446dc 100755 --- a/utils/publish/feature--cron-or-supervisord.sh +++ b/utils/publish/feature--cron-or-supervisord.sh @@ -26,9 +26,9 @@ fi echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin # Build and push as staging. -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f Dockerfile.supervisord . -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f Dockerfile.cron . -docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-bash -f Dockerfile.bash . +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f assets/supervisord/Dockerfile . +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f assets/cron/Dockerfile . +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-bash -f assets/bash/Dockerfile . docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-bash From d03bed11e255ba86623e6642dfdc7cb18cef50a0 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:39:58 +0200 Subject: [PATCH 40/44] Go with the cron alternative for the staging and stable releases --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3272c7f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +FROM debian:jessie-slim + +# Prevent the packages installation to halt. +ENV DEBIAN_FRONTEND noninteractive +# Create the seafile client user. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 + +# Copy over the Docker related files. +COPY utils/build/import-seafile-apt-key.sh / +COPY assets/cron/docker-entrypoint.sh /entrypoint.sh + +# Safely import Seafile APT key, then install both seafile-cli and supervisord. +RUN mkdir -p /etc/apt/sources.list.d/ ;\ + echo "deb http://deb.seadrive.org jessie main" \ + > /etc/apt/sources.list.d/seafile.list ;\ + bash /import-seafile-apt-key.sh ;\ + apt-get update ;\ + apt-get install \ + -o Dpkg::Options::="--force-confold" \ + -y \ + seafile-cli \ + cron ;\ + apt-get clean ;\ + apt-get autoclean \ + -o APT::Clean-Installed=true ;\ + rm \ + -f \ + /var/log/fsck/*.log \ + /var/log/apt/*.log \ + /var/cache/debconf/*.dat-old \ + /import-seafile-apt-key.sh ;\ + mkdir /volume/ ;\ + echo "seafuser" > /etc/cron.allow ;\ + echo "*/20 * * * * /bin/bash /home/seafuser/seafile-healthcheck.sh" \ + > /var/spool/cron/crontabs/seafuser ;\ + groupadd -g $GID -o $UNAME ;\ + useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME + +# Copy over the required files for Seafile/SupervisorD. +COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh +COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh + +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] From 16dd5a071aea4946f12e89f1029a580a97c33d6e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:46:40 +0200 Subject: [PATCH 41/44] Remove _waiting for sync_ from the restart black list --- assets/bash/seafile-healthcheck.sh | 2 +- assets/cron/seafile-healthcheck.sh | 2 +- assets/supervisord/seafile-healthcheck.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/bash/seafile-healthcheck.sh b/assets/bash/seafile-healthcheck.sh index 16f60d4..9b05e63 100755 --- a/assets/bash/seafile-healthcheck.sh +++ b/assets/bash/seafile-healthcheck.sh @@ -23,7 +23,7 @@ # then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't. seaf=/usr/bin/seaf-cli -dont_restart_on=("downloading" "committing" "waiting for sync") +dont_restart_on=("downloading" "committing") restart=true sleep 10s diff --git a/assets/cron/seafile-healthcheck.sh b/assets/cron/seafile-healthcheck.sh index 2f41124..663e03b 100755 --- a/assets/cron/seafile-healthcheck.sh +++ b/assets/cron/seafile-healthcheck.sh @@ -23,7 +23,7 @@ # then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't. seaf=/usr/bin/seaf-cli -dont_restart_on=("downloading" "committing" "waiting for sync") +dont_restart_on=("downloading" "committing") restart=true while IFS=$'\t' read -r name status progress; do diff --git a/assets/supervisord/seafile-healthcheck.sh b/assets/supervisord/seafile-healthcheck.sh index 16f60d4..9b05e63 100755 --- a/assets/supervisord/seafile-healthcheck.sh +++ b/assets/supervisord/seafile-healthcheck.sh @@ -23,7 +23,7 @@ # then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't. seaf=/usr/bin/seaf-cli -dont_restart_on=("downloading" "committing" "waiting for sync") +dont_restart_on=("downloading" "committing") restart=true sleep 10s From 9c3942000e3698cd520e4d551af0a5df2c3b4312 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:51:35 +0200 Subject: [PATCH 42/44] Document changes from branches feature--cron-or-supervisord and feature--infinite-restart-into-healthchecks into v1.2.0 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8b25b..dfd5ef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.2.0] - 2019/05/02 +- Replace _supervisord_ with _cron_ for running the front job that keeps the container up. It uses less resources. +- Improve the __infinite-seaf-cli-start.sh__ into __seafile-healthcheck.sh__. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic. ### [1.1.2] - 2019/04/18 - Slim down the Docker image, from 102MB to 67MB, gaining 35MB, reducing size by 34%. ### [1.1.1] - 2019/04/18 From 96aaa5911457711a73a85ffe7ec998fb57683b0a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 15:57:22 +0200 Subject: [PATCH 43/44] Push the version to v1.2.0, remove permanent/obsolete version from this document --- README.md | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ed8ac59..57e975d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![1.1.2 build status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.1.2/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.1.2) +[![1.2.0 build status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.2.0/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.2.0) [![Docker pulls](https://img.shields.io/docker/pulls/flowgunso/seafile-client.svg)](https://hub.docker.com/r/flowgunso/seafile-client) [![Licensed under GPLv3](https://img.shields.io/badge/License-GPLv3-red.svg)](https://www.gnu.org/licenses/gpl-3.0) [![@gitlab.com/flwgns-docker/seafile-client](https://img.shields.io/badge/Source%20code-GitLab-red.svg)](https://gitlab.com/flwgns-docker/seafile-client/) @@ -8,32 +8,16 @@ Weekly stable release are built every Monday at 6AM UTC+2. Permanent stable releases will not be built again. -You can rely on the weekly stable releases. They are stable. - ## Weekly stable releases. -[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.2), -[`1.1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.2), -[`1.1.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.2), -[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.2) - -## Permanent stable releases. -[`1.1.1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.1): -Release previous to the slim down. Image is larger than 100MB. +[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0), +[`1.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0), +[`1.2.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0), +[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0) ## Developmental releases. [`staging`](https://gitlab.com/flwgns-docker/seafile-client/tree/staging): The purpose of this release is to test feature and make them available to anyone. -## Obsolete releases. -[`1.1.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.1.0) -see [issue #3](https://gitlab.com/flwgns-docker/seafile-client/issues/3). - -[`1.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.6) and it's revision -[`1.0.6`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.6), -[`1.0.3`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3), -[`1.0.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.2), -[`1.0.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.0) are now obsolete. - # Purpose Docker Seafile Client allow you to sync a Seafile library within a container. From 50a119a98b5aba39e1eece236badf66fe72a2ae2 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Thu, 2 May 2019 16:22:12 +0200 Subject: [PATCH 44/44] Add a newline to separate versions --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfd5ef5..49efa52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [1.2.0] - 2019/05/02 - Replace _supervisord_ with _cron_ for running the front job that keeps the container up. It uses less resources. - Improve the __infinite-seaf-cli-start.sh__ into __seafile-healthcheck.sh__. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic. + ### [1.1.2] - 2019/04/18 - Slim down the Docker image, from 102MB to 67MB, gaining 35MB, reducing size by 34%. ### [1.1.1] - 2019/04/18