From 633d4e1d098bd53abb8d4fd84b6ea331ed680417 Mon Sep 17 00:00:00 2001 From: Fred Date: Thu, 18 Apr 2024 11:55:18 +0000 Subject: [PATCH] Update 2 files - /squid/run.sh - /Dockerfile --- Dockerfile | 11 ++++++----- squid/run.sh | 12 +++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f40067..cdd5d77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,8 @@ RUN echo "deb-src http://deb.debian.org/debian bookworm main contrib" >> /etc/ap --program-prefix= \ --libdir=/usr/lib \ --libexecdir=/usr/lib/squid \ - --localstatedir=/var \ - --sharedstatedir=/usr/com \ + --localstatedir=/run \ + --sharedstatedir=/var/lib \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --enable-icap-client \ @@ -38,7 +38,7 @@ RUN echo "deb-src http://deb.debian.org/debian bookworm main contrib" >> /etc/ap --enable-ssl \ --enable-ssl-crtd \ --with-openssl \ - --enable-storeio="aufs,diskd,ufs" \ + --enable-storeio="aufs,diskd,ufs,rock" \ --exec-prefix=/usr \ --enable-auth-basic="LDAP" \ --enable-auth-digest="LDAP" \ @@ -51,7 +51,7 @@ RUN echo "deb-src http://deb.debian.org/debian bookworm main contrib" >> /etc/ap --with-filedescriptors=48000 \ --enable-delay-pools \ --with-large-files \ - --with-pidfile=/squid/squid.pid \ + --with-pidfile=/run/squid.pid \ --with-default-user=squid \ --enable-removal-policies="lru,heap" \ && make \ @@ -98,6 +98,7 @@ RUN adduser --no-create-home --uid 1161 --group --system squid \ && echo "access_log stdio:/var/log/squid/access.log" >> /etc/squid/squid.conf \ && echo "cache_log /var/log/squid/cache.log" >> /etc/squid/squid.conf \ && echo "cache_effective_user squid" >> /etc/squid/squid.conf \ + && echo "pid_filename /run/squid.pid" >> /etc/squid/squid.conf \ # Removed in 5.8, needed for test && sed -i '/http_access deny all/ihttp_access allow localnet' /etc/squid/squid.conf \ # Packages dependencies installation for running and clean again @@ -110,4 +111,4 @@ HEALTHCHECK CMD squidclient mgr:info | grep "HTTP/1.1 200 OK" || exit 1 EXPOSE 3128 ENTRYPOINT ["dumb-init"] USER squid -CMD ["bash", "-c", "/squid/run.sh && squid -N -n $HOSTNAME"] +CMD ["bash", "-c", "/squid/run.sh"] diff --git a/squid/run.sh b/squid/run.sh index 247375a..192980f 100644 --- a/squid/run.sh +++ b/squid/run.sh @@ -1,8 +1,10 @@ #!/bin/bash - -if [ -e "/squid/squid.pid" ];then +USER=$( grep -m 1 ^cache_effective_user /etc/squid/squid.conf | awk '{ print ($2) }' ) +PID=$( grep -m 1 ^pid_filename /etc/squid/squid.conf | awk '{ print ($2) }' ) +] +if [ -e "$PID" ];then echo "Squid pid: Already running ?" - rm /squid/squid.pid + rm $PÏD pkill squid exit 1 fi @@ -17,7 +19,7 @@ else touch "/var/spool/squid/$HOSTNAME" fi -while test -e /tmp/$HOSTNAME.pid +while test -e $PID do echo "cache is generated/checked" sleep 1 @@ -42,4 +44,4 @@ fi echo "Starting: squid" # Run autoreload: IN BACKGROUND /squid/autoreload.sh & - +squid --foreground -N -n "$HOSTNAME"