#!/usr/sbin/cfagent -f

control:
   any::
   actionsequence = ( editfiles )
   EditFileSize = ( 300000 )

editfiles:
   any::
	{ ${target}/etc/adzapper.conf
	  ## Configure adzapper:
	  ReplaceAll 'ZAP_MODE=""' With 'ZAP_MODE="CLEAR"'
	}

	{ ${target}/etc/squid3/squid.conf
	  ## Define local network:
	  ReplaceAll "#acl localnet src 10.0.0.0/8" With "acl localnet src ${SUBNETMASK}"

	  ## Allow CUPS access:
	  BeginGroupIfNoSuchLine 'acl SSL_ports port 631$(tab)$(tab)# cups'
	    LocateLineMatching 'acl SSL_ports port 443.*'
	    InsertLine 'acl SSL_ports port 631$(tab)$(tab)# cups'
	    LocateLineMatching 'acl Safe_ports port 443.*'
	    InsertLine 'acl Safe_ports port 631$(tab)$(tab)# cups'
	  EndGroup

	  ## Allow local network:
	  BeginGroupIfNoSuchLine "http_access allow localnet"
	    LocateLineMatching "http_access allow localhost"
	    InsertLine "http_access allow localnet"
	  EndGroup

	  ## Use disk cache:
	  ReplaceAll "#cache_dir ufs /var/spool/squid3 100 16 256" With "cache_dir ufs /var/spool/squid3 1000 16 256"

	  ## Define url_rewrite_program:
	  BeginGroupIfNoSuchLine "url_rewrite_program /usr/bin/adzapper.wrapper"
	     LocateLineMatching "#  TAG: url_rewrite_program"
	     InsertLine "url_rewrite_program /usr/bin/adzapper.wrapper"
	  EndGroup
	}
