]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/commitdiff
squid: Added systemd init file and fixed some permissions.
authorChristian Schmidt <christian.schmidt@iipfire.org>
Sat, 29 Oct 2011 09:24:02 +0000 (09:24 +0000)
committerChristian Schmidt <christian.schmidt@iipfire.org>
Sat, 29 Oct 2011 09:24:02 +0000 (09:24 +0000)
squid/cache_swap.sh [new file with mode: 0644]
squid/squid.nm
squid/squid.sysconfig [new file with mode: 0644]
squid/systemd/squid.service [new file with mode: 0644]

diff --git a/squid/cache_swap.sh b/squid/cache_swap.sh
new file mode 100644 (file)
index 0000000..b714e66
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+if [ -f /etc/sysconfig/squid ]; then
+       . /etc/sysconfig/squid
+fi
+
+SQUID_CONF=${SQUID_CONF:-"/etc/squid/squid.conf"}
+
+CACHE_SWAP=`sed -e 's/#.*//g' $SQUID_CONF | \
+       grep cache_dir | awk '{ print $3 }'`
+
+for adir in $CACHE_SWAP; do
+       if [ ! -d $adir/00 ]; then
+               echo -n "init_cache_dir $adir... "
+               squid -z -F -f $SQUID_CONF >> /var/log/squid/squid.out 2>&1
+       fi
+done
index 59a8d9780dbc97d34450880a4a905966707f9c75..34dfd5a740634a15b5b76f605dbacd3bb8c0cc95 100644 (file)
@@ -6,7 +6,7 @@
 name       = squid
 major_ver  = 3.1
 version    = %{major_ver}.16
-release    = 2
+release    = 3
 
 maintainer = Christian Schmidt <christian.schmidt@ipfire.org>
 groups     = Networking/Daemons
@@ -99,9 +99,14 @@ build
                echo "visible_hostname %{DISTRO_NAME}" >> %{BUILDROOT}/etc/squid/squid.conf
                echo "cache_effective_user squid" >> %{BUILDROOT}/etc/squid/squid.conf
                echo "cache_effective_group squid" >> %{BUILDROOT}/etc/squid/squid.conf
-
+               
                chown -Rv squid:squid %{BUILDROOT}/var/log/squid %{BUILDROOT}/var/log/cache %{BUILDROOT}/var/cache/squid
                chmod 600 %{BUILDROOT}/var/cache/squid
+               mkdir -pv %{BUILDROOT}/etc/sysconfig
+               cp -vf %{DIR_SOURCE}/squid.sysconfig %{BUILDROOT}/etc/sysconfig/squid
+               cp -vf %{DIR_SOURCE}/cache_swap.sh %{BUILDROOT}/usr/lib/squid/
+               chmod 755 %{BUILDROOT}/usr/lib/squid/cache_swap.sh
+               chown -Rv squid:squid %{BUILDROOT}/usr/lib/squid/cache_swap.sh
        end
 end
 
@@ -113,12 +118,35 @@ end
 
 packages
        package %{name}
-               prerequires = shadow-utils
+               prerequires = shadow-utils systemd-units
+
+               configfiles
+                       /etc/squid.conf
+                       /etc/sysconfig/squid
+               end
 
                script prein
                        %{create_user}
                end
-       
+
+               script postin
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+
+               script preun
+                       /bin/systemctl --no-reload disable squid.service >/dev/null 2>&1 || :
+                       /bin/systemctl stop squid.service >/dev/null 2>&1 || :
+               end
+
+               script postun
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+
+               script postup
+                       /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+                       /bin/systemctl try-restart squid.service >/dev/null 2>&1 || :
+               end
+
                requires = /usr/bin/smbclient
 
                filter_requires = perl\(Authen::Smb\)
diff --git a/squid/squid.sysconfig b/squid/squid.sysconfig
new file mode 100644 (file)
index 0000000..3864bd8
--- /dev/null
@@ -0,0 +1,9 @@
+# default squid options
+SQUID_OPTS=""
+
+# Time to wait for Squid to shut down when asked. Should not be necessary
+# most of the time.
+SQUID_SHUTDOWN_TIMEOUT=100
+
+# default squid conf file
+SQUID_CONF="/etc/squid/squid.conf"
diff --git a/squid/systemd/squid.service b/squid/systemd/squid.service
new file mode 100644 (file)
index 0000000..2c0c98e
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Squid caching proxy
+After=syslog.target network.target
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/squid
+ExecStartPre=/usr/lib/squid/cache_swap.sh
+ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF
+ExecReload=/usr/sbin/squid $SQUID_OPTS -k reconfigure -f $SQUID_CONF
+ExecStop=/usr/sbin/squid -k shutdown -f $SQUID_CONF
+
+[Install]
+WantedBy=multi-user.target