Subversion Repositories ALCASAR

Rev

Rev 1357 | Rev 1359 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1357 Rev 1358
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 1357 2014-05-22 15:10:39Z richard $ 
2
#  $Id: alcasar.sh 1358 2014-05-23 12:26:25Z richard $ 
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
 
5
 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
7
# Ce programme est un logiciel libre ; This software is free and open source
7
# Ce programme est un logiciel libre ; This software is free and open source
Line 774... Line 774...
774
	cp -f $DIR_CONF/radius/dialup.conf /etc/raddb/sql/mysql/dialup.conf
774
	cp -f $DIR_CONF/radius/dialup.conf /etc/raddb/sql/mysql/dialup.conf
775
# counter.conf modification (change the Max-All-Session-Time counter)
775
# counter.conf modification (change the Max-All-Session-Time counter)
776
	[ -e /etc/raddb/sql/mysql/counter.conf.default ] || cp /etc/raddb/sql/mysql/counter.conf /etc/raddb/sql/mysql/counter.conf.default
776
	[ -e /etc/raddb/sql/mysql/counter.conf.default ] || cp /etc/raddb/sql/mysql/counter.conf /etc/raddb/sql/mysql/counter.conf.default
777
	cp -f $DIR_CONF/radius/counter.conf /etc/raddb/sql/mysql/counter.conf
777
	cp -f $DIR_CONF/radius/counter.conf /etc/raddb/sql/mysql/counter.conf
778
	chown -R radius:radius /etc/raddb/sql/mysql/*
778
	chown -R radius:radius /etc/raddb/sql/mysql/*
779
# insures that mysql is up before radius start
779
# make certain that mysql is up before radius start
-
 
780
	[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
780
	[ -e $SED "s?^After=.*?After=syslog.target network.target mysqld.service?g" /lib/systemd/system/radiusd.service
781
	$SED "s?^After=.*?After=syslog.target network.target mysqld.service?g" /lib/systemd/system/radiusd.service
781
 
-
 
-
 
782
	systemctl daemon-reload
782
} # End param_radius ()
783
} # End param_radius ()
783
 
784
 
784
##########################################################################
785
##########################################################################
785
##			Function "param_web_radius"			##
786
##			Function "param_web_radius"			##
786
## - Import, modification et paramètrage de l'interface "dialupadmin"	##
787
## - Import, modification et paramètrage de l'interface "dialupadmin"	##
Line 1041... Line 1042...
1041
##			Fonction "antivirus"			##
1042
##			Fonction "antivirus"			##
1042
## - configuration of havp, libclamav and freshclam		##
1043
## - configuration of havp, libclamav and freshclam		##
1043
##################################################################
1044
##################################################################
1044
antivirus ()		
1045
antivirus ()		
1045
{
1046
{
1046
# création de l'usager 'havp'
1047
# create 'havp' user
1047
	havp_exist=`grep havp /etc/passwd|wc -l`
1048
	havp_exist=`grep havp /etc/passwd|wc -l`
1048
	if [ "$havp_exist" == "1" ]
1049
	if [ "$havp_exist" == "1" ]
1049
	then
1050
	then
1050
	      userdel -r havp 2>/dev/null
1051
	      userdel -r havp 2>/dev/null
1051
	      groupdel havp 2>/dev/null
1052
	      groupdel havp 2>/dev/null
1052
	fi
1053
	fi
1053
	groupadd -f havp
1054
	groupadd -f havp
1054
	useradd -r -g havp -s /bin/false -c "system user for havp" havp
1055
	useradd -r -g havp -s /bin/false -c "system user for havp" havp
1055
	mkdir -p /var/tmp/havp /var/log/havp
1056
	mkdir -p /var/tmp/havp /var/log/havp
1056
	chown -R havp /var/tmp/havp /var/log/havp /var/run/havp
1057
	chown -R havp /var/tmp/havp /var/log/havp /var/run/havp
1057
# configuration d'HAVP
-
 
1058
	[ -e /etc/havp/havp.config.default ] || cp /etc/havp/havp.config /etc/havp/havp.config.default
1058
	[ -e /etc/havp/havp.config.default ] || cp /etc/havp/havp.config /etc/havp/havp.config.default
1059
	$SED "/^REMOVETHISLINE/d" /etc/havp/havp.config
1059
	$SED "/^REMOVETHISLINE/d" /etc/havp/havp.config
1060
	$SED "s?^# PORT.*?PORT 8090?g" /etc/havp/havp.config				# datas come on 8090			
1060
	$SED "s?^# PORT.*?PORT 8090?g" /etc/havp/havp.config				# datas come on 8090			
1061
	$SED "s?^# BIND_ADDRESS.*?BIND_ADDRESS 127.0.0.1?g" /etc/havp/havp.config	# we listen only on loopback
1061
	$SED "s?^# BIND_ADDRESS.*?BIND_ADDRESS 127.0.0.1?g" /etc/havp/havp.config	# we listen only on loopback
1062
	$SED "s?^# TIMEFORMAT.*?TIMEFORMAT %Y %b %d %H:%M:%S?g" /etc/havp/havp.config	# Log format
1062
	$SED "s?^# TIMEFORMAT.*?TIMEFORMAT %Y %b %d %H:%M:%S?g" /etc/havp/havp.config	# Log format
Line 1067... Line 1067...
1067
	$SED "s?^# SKIPMIME.*?SKIPMIME image\/\* video\/\* audio\/\*?g" /etc/havp/havp.config # doesn't scan some multimedia files
1067
	$SED "s?^# SKIPMIME.*?SKIPMIME image\/\* video\/\* audio\/\*?g" /etc/havp/havp.config # doesn't scan some multimedia files
1068
# skip checking of youtube flow (too heavy load / risk too low)
1068
# skip checking of youtube flow (too heavy load / risk too low)
1069
	[ -e /etc/havp/whitelist.default ] || cp /etc/havp/whitelist /etc/havp/whitelist.default
1069
	[ -e /etc/havp/whitelist.default ] || cp /etc/havp/whitelist /etc/havp/whitelist.default
1070
	echo "# Whitelist youtube flow" >> /etc/havp/whitelist
1070
	echo "# Whitelist youtube flow" >> /etc/havp/whitelist
1071
	echo "*.youtube.com/*" >> /etc/havp/whitelist
1071
	echo "*.youtube.com/*" >> /etc/havp/whitelist
1072
# remplacement du fichier d'initialisation
1072
# replacement of init script
1073
	[ -e /etc/init.d/havp.default ] || cp /etc/init.d/havp /etc/init.d/havp.default
1073
	[ -e /etc/init.d/havp.default ] || cp /etc/init.d/havp /etc/init.d/havp.default
1074
# if keep old init file : 
-
 
1075
	cp -f $DIR_CONF/havp-init /etc/init.d/havp
1074
	cp -f $DIR_CONF/havp-init /etc/init.d/havp
1076
# replace the on remplace la page d'interception (template)
1075
# replace of the intercept page (template)
1077
	cp -f $DIR_CONF/virus-fr.html /etc/havp/templates/fr/virus.html
1076
	cp -f $DIR_CONF/virus-fr.html /etc/havp/templates/fr/virus.html
1078
	cp -f $DIR_CONF/virus-en.html /etc/havp/templates/en/virus.html
1077
	cp -f $DIR_CONF/virus-en.html /etc/havp/templates/en/virus.html
1079
# update virus database every 2 hours (24h/12)
1078
# update virus database every 4 hours (24h/6)
1080
	[ -e /etc/freshclam.conf.default ] || cp /etc/freshclam.conf /etc/freshclam.conf.default
1079
	[ -e /etc/freshclam.conf.default ] || cp /etc/freshclam.conf /etc/freshclam.conf.default
1081
	$SED "s?^Checks.*?Checks 6?g" /etc/freshclam.conf
1080
	$SED "s?^Checks.*?Checks 6?g" /etc/freshclam.conf
1082
	$SED "s?^NotifyClamd.*?# NotifyClamd /etc/clamd.conf?g" /etc/freshclam.conf
1081
	$SED "s?^NotifyClamd.*?# NotifyClamd /etc/clamd.conf?g" /etc/freshclam.conf
1083
	$SED "/^DatabaseMirror/i DatabaseMirror db.fr.clamav.net" /etc/freshclam.conf
1082
	$SED "/^DatabaseMirror/i DatabaseMirror db.fr.clamav.net" /etc/freshclam.conf
1084
	$SED "/^DatabaseMirror/i DatabaseMirror switch.clamav.net" /etc/freshclam.conf
1083
	$SED "/^DatabaseMirror db.fr.clamav.net/i DatabaseMirror switch.clamav.net" /etc/freshclam.conf
-
 
1084
	$SED "s?MaxAttempts.*?MaxAttempts 3?g" /etc/freshclam.conf
1085
# Copy of the main virus database
1085
# Copy of the main virus database
1086
	rm -f /var/lib/clamav/*.cld # in case of old database scheme
1086
	rm -f /var/lib/clamav/*.cld # in case of old database scheme
1087
	cp -f $DIR_CONF/clamav-main.cvd /var/lib/clamav/main.cvd
1087
	cp -f $DIR_CONF/clamav-main.cvd /var/lib/clamav/main.cvd
1088
	/usr/bin/freshclam
1088
	/usr/bin/freshclam
1089
}
1089
}
Line 1093... Line 1093...
1093
## - Ulog config for multi-log files 						##
1093
## - Ulog config for multi-log files 						##
1094
##################################################################################
1094
##################################################################################
1095
param_ulogd ()
1095
param_ulogd ()
1096
{
1096
{
1097
# Three instances of ulogd (three different logfiles)
1097
# Three instances of ulogd (three different logfiles)
-
 
1098
	cp -f /lib/systemd/system/ulogd.service /lib/systemd/system/ulogd-ssh.service /lib/systemd/system/ulogd-ext-access.service
-
 
1099
	mv /lib/systemd/system/ulogd.service /lib/systemd/system/ulogd-traceability.service
1098
	[ -d /var/log/firewall ] || mkdir -p /var/log/firewall
1100
	[ -d /var/log/firewall ] || mkdir -p /var/log/firewall
1099
	nl=1
1101
	nl=1
1100
	for log_type in tracability ssh ext-access
1102
	for log_type in traceability ssh ext-access
1101
	do
1103
	do
1102
		[ -e /var/log/firewall/$log_type.log ] || touch /var/log/firewall/$log_type.log
1104
		[ -e /var/log/firewall/$log_type.log ] || touch /var/log/firewall/$log_type.log
1103
		cp -f /etc/ulogd.conf /etc/ulogd-$log_type.conf
1105
		cp -f /etc/ulogd.conf /etc/ulogd-$log_type.conf
1104
		$SED "s?^nlgroup=.*?nlgroup=$nl?g" /etc/ulogd-$log_type.conf 
1106
		$SED "s?^nlgroup=.*?nlgroup=$nl?g" /etc/ulogd-$log_type.conf 
1105
		$SED '/OPRINT/,$d' /etc/ulogd-$log_type.conf
1107
		$SED '/OPRINT/,$d' /etc/ulogd-$log_type.conf
1106
		cat << EOF >> /etc/ulogd-$log_type.conf
1108
		cat << EOF >> /etc/ulogd-$log_type.conf
1107
[LOGEMU]
1109
[LOGEMU]
1108
file="/var/log/firewall/$log_type.log"
1110
file="/var/log/firewall/$log_type.log"
1109
sync=1
1111
sync=1
1110
EOF
1112
EOF
-
 
1113
		$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/ulogd -C /etc/ulogd-$log_type.conf?g" /lib/systemd/system/ulogd-$log_type.service
1111
		nl=`expr $nl + 1`
1114
		nl=`expr $nl + 1`
1112
	done
1115
	done
1113
	chown -R root:apache /var/log/firewall
1116
	chown -R root:apache /var/log/firewall
1114
	chmod 750 /var/log/firewall
1117
	chmod 750 /var/log/firewall
1115
	chmod 640 /var/log/firewall/*
1118
	chmod 640 /var/log/firewall/*
1116
	[ -e /etc/init.d/ulogd.default ] || cp /etc/init.d/ulogd /etc/init.d/ulogd.default
-
 
1117
	cp -f $DIR_CONF/ulogd-init /etc/init.d/ulogd
-
 
1118
}  # End of param_ulogd ()
1119
}  # End of param_ulogd ()
1119
 
1120
 
1120
 
1121
 
1121
##########################################################
1122
##########################################################
1122
##              Function "param_nfsen"			##
1123
##              Function "param_nfsen"			##
Line 1263... Line 1264...
1263
EOF
1264
EOF
1264
# Create dnsmasq-blacklist and dnsmasq-whitelist unit
1265
# Create dnsmasq-blacklist and dnsmasq-whitelist unit
1265
	cp -f /lib/systemd/system/dnsmasq.service /lib/systemd/system/dnsmasq-blacklist.service /lib/systemd/system/dnsmasq-whitelist.service
1266
	cp -f /lib/systemd/system/dnsmasq.service /lib/systemd/system/dnsmasq-blacklist.service /lib/systemd/system/dnsmasq-whitelist.service
1266
	$SED "s?^ExecStart=.*?ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-blacklist.conf?g" /lib/systemd/system/dnsmasq-blacklist.service
1267
	$SED "s?^ExecStart=.*?ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-blacklist.conf?g" /lib/systemd/system/dnsmasq-blacklist.service
1267
	$SED "s?^ExecStart=.*?ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-whitelist.conf?g" /lib/systemd/system/dnsmasq-whitelist.service
1268
	$SED "s?^ExecStart=.*?ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-whitelist.conf?g" /lib/systemd/system/dnsmasq-whitelist.service
1268
# Start after chilli which create tun0
1269
# TODO Start after chilli which create tun0
1269
#	$SED "s?^# chkconfig:.*?# chkconfig: 2345 99 40?g" /etc/init.d/dnsmasq
1270
#	$SED "s?^# chkconfig:.*?# chkconfig: 2345 99 40?g" /etc/init.d/dnsmasq
1270
} # End dnsmasq
1271
} # End dnsmasq
1271
 
1272
 
1272
##########################################################
1273
##########################################################
1273
##		Fonction "BL"				##
1274
##		Fonction "BL"				##
Line 1445... Line 1446...
1445
	echo "SSH=off" >> $CONF_FILE
1446
	echo "SSH=off" >> $CONF_FILE
1446
	echo 'SSH_ADMIN_FROM=0.0.0.0/0.0.0.0' >> $CONF_FILE
1447
	echo 'SSH_ADMIN_FROM=0.0.0.0/0.0.0.0' >> $CONF_FILE
1447
	echo "QOS=off" >> $CONF_FILE
1448
	echo "QOS=off" >> $CONF_FILE
1448
	echo "LDAP=off" >> $CONF_FILE
1449
	echo "LDAP=off" >> $CONF_FILE
1449
	echo "LDAP_IP=0.0.0.0/0.0.0.0" >> $CONF_FILE
1450
	echo "LDAP_IP=0.0.0.0/0.0.0.0" >> $CONF_FILE
1450
	echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
1451
	echo "WEB_ANTIVIRUS=on" >> $CONF_FILE # TODO to remove
1451
	echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
1452
	echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE # TODO to remove
1452
	echo "DNS_FILTERING=off" >> $CONF_FILE
1453
	echo "DNS_FILTERING=off" >> $CONF_FILE # TODO to remove
1453
	echo "YOUTUBE_ID=ABCD1234567890abcdef" >> $CONF_FILE
1454
	echo "YOUTUBE_ID=ABCD1234567890abcdef" >> $CONF_FILE
1454
	echo "MULTIWAN=off" >> $CONF_FILE
1455
	echo "MULTIWAN=off" >> $CONF_FILE
1455
	echo "FAILOVER=30" >> $CONF_FILE
1456
	echo "FAILOVER=30" >> $CONF_FILE
1456
	echo "## WANx=active,@IPx/mask,GWx,Weight,MTUx" >> $CONF_FILE
1457
	echo "## WANx=active,@IPx/mask,GWx,Weight,MTUx" >> $CONF_FILE
1457
	echo "#WAN1=\"1,$EXTIF:1,192.168.2.20/24,192.168.2.6,1,1500\"" >> $CONF_FILE
1458
	echo "#WAN1=\"1,$EXTIF:1,192.168.2.20/24,192.168.2.6,1,1500\"" >> $CONF_FILE
Line 1498... Line 1499...
1498
 
1499
 
1499
[Install]
1500
[Install]
1500
WantedBy=multi-user.target
1501
WantedBy=multi-user.target
1501
EOF
1502
EOF
1502
# processes launched at boot time (SYSV)
1503
# processes launched at boot time (SYSV)
1503
	for i in chilli netfs havp 
1504
	for i in chilli havp 
1504
	do
1505
	do
1505
		/sbin/chkconfig --add $i
1506
		/sbin/chkconfig --add $i
1506
	done
1507
	done
1507
# processes launched at boot time (Systemctl)
1508
# processes launched at boot time (Systemctl)
1508
	for i in alcasar-load_balancing nfsen mysqld httpd ntpd iptables ulogd dnsmasq radiusd dansguardian freshclam
1509
	for i in alcasar-load_balancing nfsen mysqld httpd ntpd iptables ulogd dnsmasq radiusd dansguardian freshclam