#!/bin/sh # postinst script for lliurex-guard-standalone # # see: dh_installdeb(1) set -e PACKAGE_NAME="lliurex-guard-standalone" # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package #TEMPLATE_PATH="/etc/lliurex-guard-standalone/templates" #SQUID_PATH="/etc/squid3/lliurex" case "$1" in configure) # Enable n4d modules n4d-modules enable-plugin /etc/n4d/conf.d/N4dGuard || true # Create llx-guard-dst-domains if not exists [ -e /etc/squid3/lliurex/llx-guard-dst-domains.conf ] || touch /etc/squid3/lliurex/llx-guard-dst-domains.conf # Adding autoload of iptables in autorun cat /etc/lliurex-guard-standalone/templates/squid.conf | sed -e "s/#{LliureXGuardDefaultPolicy}/http_access allow all/" > /etc/squid3/squid.conf # Adding line "exit 0" to /etc/rc.local if not exists before adding iptables call [ `grep -v '^#' /etc/rc.local | grep "exit 0" | wc -l` -ne 0 ] || echo "exit 0" >> /etc/rc.local # Start iptables if [ `cat /etc/rc.local | grep -v '^#' |grep /etc/lliurex-guard-standalone/iptables.conf | wc -l` -eq 0 ]; then sed 's/exit 0/\/etc\/lliurex-guard-standalone\/iptables.conf\n&/' /etc/rc.local > /tmp/rc.local; cp /tmp/rc.local /etc/rc.local; fi chmod +x /etc/lliurex-guard-standalone/iptables.conf /etc/lliurex-guard-standalone/iptables.conf # Setting default template: allow-all if not exists [ -e /etc/lliurex-guard-standalone/config/running_template ] || echo '{"running_template":"'allow-all'"}' > /etc/lliurex-guard-standalone/config/running_template # Creating squid.conf accordint to running template templatefile=`cat /etc/lliurex-guard-standalone/config/running_template` template=$(echo $templatefile|cut -d ":" -f2 | cut -d "}" -f1| sed -e 's%"%%g') # Restart squid via n4d #invoke-rc.d squid3 restart || true n4d-client -c N4dGuard -m apply_template -r -a $template || true ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0