Subversion Repositories ALCASAR

Rev

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

Rev 2488 Rev 2521
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-conf.sh 2488 2018-02-25 14:53:54Z lucas.echard $
2
# $Id: alcasar-conf.sh 2521 2018-04-02 19:46:16Z armand.ito $
3
 
3
 
4
# alcasar-conf.sh
4
# alcasar-conf.sh
5
# by REXY
5
# by 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
 
Line 19... Line 19...
19
DIR_UPDATE="/tmp/conf"					# répertoire de stockage des fichier de conf pour une mise à jour
19
DIR_UPDATE="/tmp/conf"					# répertoire de stockage des fichier de conf pour une mise à jour
20
DIR_WEB="/var/www/html"					# répertoire du centre de gestion
20
DIR_WEB="/var/www/html"					# répertoire du centre de gestion
21
DIR_BIN="/usr/local/bin"				# scripts directory
21
DIR_BIN="/usr/local/bin"				# scripts directory
22
DIR_ETC="/usr/local/etc"				# conf directory
22
DIR_ETC="/usr/local/etc"				# conf directory
23
DIR_SHARE="/usr/local/share"				# data directory
23
DIR_SHARE="/usr/local/share"				# data directory
24
DIR_BLACKLIST="/etc/dansguardian/lists/blacklists"	# Toulouse BL directory
24
DIR_BLACKLIST="/etc/e2guardian/lists/blacklists"	# Toulouse BL directory
25
CONF_FILE="$DIR_ETC/alcasar.conf"			# main alcasar conf file
25
CONF_FILE="$DIR_ETC/alcasar.conf"			# main alcasar conf file
26
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2`		# EXTernal InterFace
26
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2`		# EXTernal InterFace
27
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`		# INTernal InterFace
27
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`		# INTernal InterFace
28
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2`
28
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2`
29
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
29
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
Line 85... Line 85...
85
		cp /var/Save/base/`ls -1t /var/Save/base|head -1` $DIR_UPDATE
85
		cp /var/Save/base/`ls -1t /var/Save/base|head -1` $DIR_UPDATE
86
# backup the logo
86
# backup the logo
87
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
87
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
88
# backup BL/WL custom files
88
# backup BL/WL custom files
89
		mkdir $DIR_UPDATE/custom_bl
89
		mkdir $DIR_UPDATE/custom_bl
90
		cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE/custom_bl/
90
		cp -f /etc/e2guardian/lists/exceptioniplist $DIR_UPDATE/custom_bl/
91
		cp -f /etc/dansguardian/lists/urlregexplist $DIR_UPDATE/custom_bl/
91
		cp -f /etc/e2guardian/lists/urlregexplist $DIR_UPDATE/custom_bl/
92
		cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE/custom_bl/
92
		cp -f /etc/e2guardian/lists/exceptionsitelist $DIR_UPDATE/custom_bl/
93
		cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE/custom_bl/
93
		cp -f /etc/e2guardian/lists/bannedsitelist $DIR_UPDATE/custom_bl/
94
		cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE/custom_bl/
94
		cp -f /etc/e2guardian/lists/exceptionurllist $DIR_UPDATE/custom_bl/
95
		cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE/custom_bl/
95
		cp -f /etc/e2guardian/lists/bannedurllist $DIR_UPDATE/custom_bl/
96
		cp -rf $DIR_BLACKLIST/ossi-* $DIR_UPDATE/custom_bl/ 2>/dev/null
96
		cp -rf $DIR_BLACKLIST/ossi-* $DIR_UPDATE/custom_bl/ 2>/dev/null
97
# backup of different conf files (main conf file, filtering, digest, etc)
97
# backup of different conf files (main conf file, filtering, digest, etc)
98
		mkdir $DIR_UPDATE/etc/
98
		mkdir $DIR_UPDATE/etc/
99
		[ -e $DIR_ETC/alcasar-ethers-info ] || cp $DIR_ETC/alcasar-ethers $DIR_ETC/alcasar-ethers-info # V3.1.2 new info file for dhcp static
99
		[ -e $DIR_ETC/alcasar-ethers-info ] || cp $DIR_ETC/alcasar-ethers $DIR_ETC/alcasar-ethers-info # V3.1.2 new info file for dhcp static
100
		cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
100
		cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
Line 132... Line 132...
132
# Import of the users database
132
# Import of the users database
133
		gzip -dc < `ls $DIR_UPDATE/alcasar-users-database*` | mysql -u$DB_USER -p$DB_PASS
133
		gzip -dc < `ls $DIR_UPDATE/alcasar-users-database*` | mysql -u$DB_USER -p$DB_PASS
134
# Retrieve local parameters
134
# Retrieve local parameters
135
		[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
135
		[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
136
# Retrieve BL/WL custom files
136
# Retrieve BL/WL custom files
137
		cp -f $DIR_UPDATE/custom_bl/exceptioniplist /etc/dansguardian/lists/
137
		cp -f $DIR_UPDATE/custom_bl/exceptioniplist /etc/e2guardian/lists/
138
		cp -f $DIR_UPDATE/custom_bl/exceptionsitelist /etc/dansguardian/lists/
138
		cp -f $DIR_UPDATE/custom_bl/exceptionsitelist /etc/e2guardian/lists/
139
		cp -f $DIR_UPDATE/custom_bl/urlregexplist /etc/dansguardian/lists/
139
		cp -f $DIR_UPDATE/custom_bl/urlregexplist /etc/e2guardian/lists/
140
		cp -f $DIR_UPDATE/custom_bl/bannedsitelist /etc/dansguardian/lists/ 
140
		cp -f $DIR_UPDATE/custom_bl/bannedsitelist /etc/e2guardian/lists/ 
141
		cp -f $DIR_UPDATE/custom_bl/exceptionurllist /etc/dansguardian/lists/
141
		cp -f $DIR_UPDATE/custom_bl/exceptionurllist /etc/e2guardian/lists/
142
		cp -f $DIR_UPDATE/custom_bl/bannedurllist /etc/dansguardian/lists/
142
		cp -f $DIR_UPDATE/custom_bl/bannedurllist /etc/e2guardian/lists/
143
		cp -rf $DIR_UPDATE/custom_bl/ossi-* $DIR_BLACKLIST/ 2>/dev/null
143
		cp -rf $DIR_UPDATE/custom_bl/ossi-* $DIR_BLACKLIST/ 2>/dev/null
144
		chown -R dansguardian:apache /etc/dansguardian/lists
144
		chown -R e2guardian:apache /etc/e2guardian/lists
145
		chmod -R g+rw /etc/dansguardian/lists
145
		chmod -R g+rw /etc/e2guardian/lists
146
# Adapt DNS/URL filtering
146
# Adapt DNS/URL filtering
147
		PARENT_SCRIPT=`basename $0`
147
		PARENT_SCRIPT=`basename $0`
148
		export PARENT_SCRIPT
148
		export PARENT_SCRIPT
149
		$DIR_BIN/alcasar-bl.sh -cat_choice
149
		$DIR_BIN/alcasar-bl.sh -cat_choice
150
		$DIR_BIN/alcasar-bl.sh -reload
150
		$DIR_BIN/alcasar-bl.sh -reload
Line 358... Line 358...
358
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
358
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
359
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
359
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
360
# tinyproxy			
360
# tinyproxy			
361
		$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
361
		$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
362
# DG + BL
362
# DG + BL
363
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
363
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/e2guardian/e2guardian.conf
364
# Watchdog
364
# Watchdog
365
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
365
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
366
# Prompts
366
# Prompts
367
		$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
367
		$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
368
# sudoers
368
# sudoers