From 266890e5cf15f0f09ee3689e7f10a442a4e8326b Mon Sep 17 00:00:00 2001 From: fredbcode Date: Mon, 15 Nov 2021 12:36:40 +0100 Subject: [PATCH] Update run.sh and push only master branch to docker hub --- Dockerfile | 2 +- gitlabci/docker-hub-arm.yml | 2 ++ gitlabci/docker-hub.yml | 3 +++ run.sh | 29 +++++++++++++---------------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66401b8..4b9de9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,7 +99,7 @@ RUN adduser --no-create-home --uid 1161 --group --system squid \ && echo "cache_log /var/log/squid/cache.log" >> /etc/squid/squid.conf \ && echo "cache_effective_user squid" >> /etc/squid/squid.conf \ # Packages dependencies installation for running and clean again - && apt-get update && apt-get install -y --no-install-recommends ca-certificates net-tools rsync libexpat1 libltdl7 libxml2 openssl ca-certificates libldap-2.4-2 libecap3 libcap2 libdb5.3 libatomic1 dumb-init \ + && apt-get update && apt-get install -y --no-install-recommends ca-certificates net-tools rsync libexpat1 libltdl7 libxml2 openssl ca-certificates libldap-2.4-2 libecap3 libcap2 libdb5.3 libatomic1 dumb-init procps \ && apt-get auto-remove -y && apt-get clean autoclean \ && rm -rf /var/lib/apt/lists/* && rm -Rf /tmp/* COPY run.sh / diff --git a/gitlabci/docker-hub-arm.yml b/gitlabci/docker-hub-arm.yml index 071fc60..66a721c 100644 --- a/gitlabci/docker-hub-arm.yml +++ b/gitlabci/docker-hub-arm.yml @@ -71,3 +71,5 @@ push-docker-hub-arm: variables: GIT_STRATEGY: none needs: ["docker-hub-test-arm"] + only: + - master diff --git a/gitlabci/docker-hub.yml b/gitlabci/docker-hub.yml index e2c0867..46fc3f0 100644 --- a/gitlabci/docker-hub.yml +++ b/gitlabci/docker-hub.yml @@ -65,3 +65,6 @@ push-docker-hub: variables: GIT_STRATEGY: none needs: ["docker-hub-test"] + only: + - master + diff --git a/run.sh b/run.sh index 5c25e34..eb98b69 100644 --- a/run.sh +++ b/run.sh @@ -1,36 +1,33 @@ #!/bin/bash set -vx -# remove previous pid (if exist) after crash -rm /var/run/squid.pid -if [ $NOAUTO == "yes" ];then - squid -z -n $HOSTNAME - squid -N -n $HOSTNAME +if [ -e "/run/squid.pid" ];then + echo "Squid pid: Already running ?" + rm /run/squid.pid + pkill squid + exit 1 fi -# + 48h -LIMIT="-cmin +2880" - -# le cache contient des repertoires pas utilisés depuis plus de $LIMIT +# Check si Au demarrage le cache contient des repertoires pas utilisés depuis plus de $LIMIT FINDTIME=$(find /var/spool/squid/$HOSTNAME/* -maxdepth 0 -type d $LIMIT | wc -l) -# Combien de rep en tout +# Combien de rep global NOWREP=$(find /var/spool/squid/$HOSTNAME/* -maxdepth 0 -type d | wc -l) -chown -R squid /var/log/squid - # Not exist or too old if [ ! -d "/var/spool/squid/$HOSTNAME" ] || [ $FINDTIME == $NOWREP ];then +# On genere/regenere squid -z -n $HOSTNAME - sleep 5 + sleep 1 else +# Remet à zero la date du rep de cache pour le prochain check touch "/var/spool/squid/$HOSTNAME" fi -while test -e /var/run/squid.pid +while test -e /var/run/squid.pid do - echo "cache is generated/checked" + echo "cache is generated/checked" sleep 1 -done +done # Find and remove old useless caches directories (not used after "LIMIT" value). sleep is only used to wait other containers are well started. mkdir /tmp/empty