summaryrefslogtreecommitdiff
path: root/net-proxy/polipo/files/polipo.crond-2
blob: 6b2d609d6d6a02cf319d70fd6360f71b754051c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# Loop through all init.d instances
for f in /etc/init.d/polipo*; do
    # only proceed if daemon is running
    "${f}" --quiet status || continue

    myname="${f#/etc/init.d/polipo}"
    conffile="/etc/polipo/config${myname}"
    pidfile="/var/run/polipo${myname}.pid"

    # check if disk cache is enabled
    polipo -v -c "${CONFFILE}" |
        awk '$1 ~ /diskCacheRoot/ { if ($3 == "(none)") exit 1}' ||
        continue

    # Expire old cached objects
    kill -USR1 $(cat "${pidfile}")
    sleep 1
    nice -n 15 su -s "/bin/sh" -c "polipo -c ${conffile} -x" polipo > /dev/null
    kill -USR2 $(cat "${pidfile}")
done