Subversion Repositories ALCASAR

Rev

Rev 1739 | Rev 1888 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1739 Rev 1827
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-bypass.sh 1739 2016-01-03 12:51:37Z richard $
2
# $Id: alcasar-bypass.sh 1827 2016-04-19 09:47:29Z raphael.pion $
3
 
3
 
4
# alcasar-bypass.sh
4
# alcasar-bypass.sh
5
# by 3abtux and Rexy
5
# by 3abtux and Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
8
# activation / désactivation du contournement de l'authentification et du filtrage WEB
8
# activation / désactivation du contournement de l'authentification et du filtrage WEB
9
# enable / disable the bypass of authenticate process and filtering
9
# enable / disable the bypass of authenticate process and filtering
10
 
10
 
11
usage="Usage: alcasar-bypass.sh {--on or -on } | {--off or -off}"
11
usage="Usage: alcasar-bypass.sh {--on or -on } | {--off or -off}"
12
SED="/bin/sed -i"
12
SED="/bin/sed -i"
13
CONF_FILE="/usr/local/etc/alcasar.conf"
13
CONF_FILE="/usr/local/etc/alcasar.conf"
14
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`				# INTernal InterFace
14
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`				# INTernal InterFace
15
 
15
 
16
nb_args=$#
16
nb_args=$#
17
args=$1
17
args=$1
18
if [ $nb_args -eq 0 ]
18
if [ $nb_args -eq 0 ]
19
then
19
then
20
	nb_args=1
20
	nb_args=1
21
	args="-h"
21
	args="-h"
22
fi
22
fi
23
case $args in
23
case $args in
24
	-\? | -h* | --h*)
24
	-\? | -h* | --h*)
25
		echo "$usage"
25
		echo "$usage"
26
		exit 0
26
		exit 0
27
		;;
27
		;;
28
	--on | -on)	
28
	--on | -on)	
29
		/usr/local/sbin/alcasar-logout.sh all
29
		/usr/local/bin/alcasar-logout.sh all
30
		/usr/bin/systemctl stop chilli
30
		/usr/bin/systemctl stop chilli
31
		cp -f /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF /etc/sysconfig/network-scripts/ifcfg-$INTIF
31
		cp -f /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF /etc/sysconfig/network-scripts/ifcfg-$INTIF
32
		ifup $INTIF
32
		ifup $INTIF
33
		sh /usr/local/bin/alcasar-iptables-bypass.sh
33
		sh /usr/local/bin/alcasar-iptables-bypass.sh
34
		DHCP=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
34
		DHCP=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
35
		if  [ $DHCP != off ] 
35
		if  [ $DHCP != off ] 
36
		then 
36
		then 
37
			$SED "s?^#route.*?&?g" /etc/dnsmasq.conf # dnsmasq become the DHCP server
37
			$SED "s?^#route.*?&?g" /etc/dnsmasq.conf # dnsmasq become the DHCP server
38
			$SED "s?^no-dhcp-interface.*?#&?g" /etc/dnsmasq.conf # 	
38
			$SED "s?^no-dhcp-interface.*?#&?g" /etc/dnsmasq.conf # 	
39
			/usr/bin/systemctl restart dnsmasq
39
			/usr/bin/systemctl restart dnsmasq
40
		fi
40
		fi
41
 
41
 
42
		rm -f /etc/cron.d/alcasar-daemon-watchdog # don't restart daemons (specially coova) 
42
		rm -f /etc/cron.d/alcasar-daemon-watchdog # don't restart daemons (specially coova) 
43
		echo "ALCASAR est en mode 'bypass'"
43
		echo "ALCASAR est en mode 'bypass'"
44
		echo "ALCASAR is in 'bypass' mode"
44
		echo "ALCASAR is in 'bypass' mode"
45
		;;
45
		;;
46
	--off | -off)
46
	--off | -off)
47
		cp -f /etc/sysconfig/network-scripts/default-ifcfg-$INTIF /etc/sysconfig/network-scripts/ifcfg-$INTIF
47
		cp -f /etc/sysconfig/network-scripts/default-ifcfg-$INTIF /etc/sysconfig/network-scripts/ifcfg-$INTIF
48
		ifup $INTIF
48
		ifup $INTIF
49
		$SED "s?^route.*?#&?g" /etc/dnsmasq.conf # 
49
		$SED "s?^route.*?#&?g" /etc/dnsmasq.conf # 
50
		$SED "s?^#no-dhcp-interface=$INTIF?no-dhcp-interface=$INTIF?g" /etc/dnsmasq.conf
50
		$SED "s?^#no-dhcp-interface=$INTIF?no-dhcp-interface=$INTIF?g" /etc/dnsmasq.conf
51
		$SED "s?^#no-dhcp-interface=tun0?no-dhcp-interface=tun0?g" /etc/dnsmasq.conf
51
		$SED "s?^#no-dhcp-interface=tun0?no-dhcp-interface=tun0?g" /etc/dnsmasq.conf
52
		$SED "s?^#no-dhcp-interface=lo?no-dhcp-interface=lo?g" /etc/dnsmasq.conf
52
		$SED "s?^#no-dhcp-interface=lo?no-dhcp-interface=lo?g" /etc/dnsmasq.conf
53
		/usr/bin/systemctl restart dnsmasq
53
		/usr/bin/systemctl restart dnsmasq
54
		/usr/bin/systemctl start chilli
54
		/usr/bin/systemctl start chilli
55
		sh /usr/local/bin/alcasar-iptables.sh
55
		sh /usr/local/bin/alcasar-iptables.sh
56
		# activation of the "daemon-watchdog" every 18'
56
		# activation of the "daemon-watchdog" every 18'
57
		cat << EOF > /etc/cron.d/alcasar-daemon-watchdog
57
		cat << EOF > /etc/cron.d/alcasar-daemon-watchdog
58
# activation du "chien de garde" (daemon-watchdog) toutes les 18'
58
# activation du "chien de garde" (daemon-watchdog) toutes les 18'
59
*/18 * * * * root /usr/local/bin/alcasar-daemon.sh > /dev/null 2>&1
59
*/18 * * * * root /usr/local/bin/alcasar-daemon.sh > /dev/null 2>&1
60
EOF
60
EOF
61
		echo "L'authentification et le filtrage sont actifs"
61
		echo "L'authentification et le filtrage sont actifs"
62
		echo "Authentication and filtering system are enabled"
62
		echo "Authentication and filtering system are enabled"
63
;;
63
;;
64
	*)
64
	*)
65
		echo "Argument inconnu :$1";
65
		echo "Argument inconnu :$1";
66
		echo "$usage"
66
		echo "$usage"
67
		exit 1
67
		exit 1
68
		;;
68
		;;
69
esac
69
esac
70
 
70