#!/bin/bash

if [ -n "$1" ] ; then
	GX_FILTER_PROFILE_OVERRIDE=$1;
fi

. /usr/share/groovix/global.conf

# per user settings
CURUSER=`cat /var/lib/groovix/session-info/current-user`
if [ -e /etc/groovix/peruser/$CURUSER/groovix.conf ] ; then
        . /etc/groovix/peruser/$CURUSER/groovix.conf
fi

if [ -n "$GX_FILTER_PROFILE_OVERRIDE" ] ; then
	GX_FILTER_PROFILE=$GX_FILTER_PROFILE_OVERRIDE;
fi



if [ -e /etc/groovix/filter/$GX_FILTER_PROFILE/squidGuard.conf ] ; then
	cp /etc/groovix/filter/$GX_FILTER_PROFILE/squidGuard.conf /etc/squidguard/squidGuard.conf
fi

if [ -e /etc/groovix/filter/$GX_FILTER_PROFILE/squid.bash ] ; then
        bash /etc/groovix/filter/$GX_FILTER_PROFILE/squid.bash
fi

if [ -e /etc/groovix/filter/$GX_FILTER_PROFILE/iptables.bash ] ; then
	bash /etc/groovix/filter/$GX_FILTER_PROFILE/iptables.bash
fi
	
if [ -e /etc/groovix/filter/$GX_FILTER_PROFILE/hosts.bash ] ; then
        bash /etc/groovix/filter/$GX_FILTER_PROFILE/hosts.bash
fi

echo "active-$GX_FILTER_PROFILE" > /var/lib/groovix/filter/last-state
