Wie man per Cron automatisch eine Leerung des Caches von Squid in pfSense ausführen kann
[2.0.1-RELEASE][admin@mypfw.teiko.hq]/root(10): vi /usr/local/bin/cleansquid.sh
/usr/local/etc/rc.d/squid.sh stop rm -rf /var/squid/cache/ mkdir -p /var/squid/cache/ chown squid:squid /var/squid/cache/ chmod 777 /var/squid/cache/ squid -z /usr/local/etc/rc.d/squid.sh start
[2.0.1-RELEASE][admin@mypfw.teiko.hq]/root(10): chmod +x /usr/local/bin/cleansquid.sh
Sollte man am besten @monthly per cron ausführen
#!/bin/bash
#!/dev/tty1
SCRIPT="echo -e 'PASSWORD' | sudo -S squid -k shutdown ; sudo rm -rf /var/spool/squid/ ; sudo mkdir /var/spool/squid ; sudo chown squid:squid /var/spool/squid ; sudo restorecon -vr /var/spool/squid ; sudo squid -z ; sudo reboot ;"
HOSTS=("192.168.1.101" "192.168.1.102")
USERNAMES=("user1" "user2")
PASSWORDS=("password1" "password2")
PASSWORDSROOT=("rootpassword1" "rootpassword2")
for i in ${!HOSTS[*]} ; do
echo ${HOSTS[i]}
SCR=${SCRIPT/PASSWORD/${PASSWORDSROOT[i]}}
sshpass -p ${PASSWORDS[i]} ssh -l ${USERNAMES[i]} ${HOSTS[i]} "${SCR}"
done
exit 0
squid farm script „build new cache“ OpenSuSE specific
CRON like: 59 23 */7 * * /bin/sh /root/build.sh
CHMOD like: chmod +x /root/build.sh
TODO: INSTALL „sshpass“ Paket
Sonar