Subversion Repositories ALCASAR

Rev

Rev 1866 | Rev 1912 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
672 richard 1
#/bin/bash
64 franck 2
# $Id: alcasar-conf.sh 1890 2016-05-17 16:08:51Z franck $
672 richard 3
 
4
# alcasar-conf.sh
865 richard 5
# by REXY
672 richard 6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# Ce script permet la mise à jour ALCASAR 
1758 richard 9
#	- création de l'archive des fichiers de configuration dans "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
10
#	- chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load)
11
#	- application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" lors d'un changement de conf réseau à chaud (alcasar-conf -apply) 
672 richard 12
# This script allows ALCASAR update 
1758 richard 13
#	- create the configuration files backup "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
14
#	- load the bachup of configuration files during the update process (alcasar-conf -load)
15
#	- apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification is needed (alcasar-conf -apply)
672 richard 16
 
865 richard 17
new="$(date +%G%m%d-%Hh%M)"  			# date et heure des fichiers
806 richard 18
fichier="alcasar-conf-$new.tar.gz"		# nom du fichier de sauvegarde
8 franck 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
478 richard 21
DIR_BIN="/usr/local/bin"			# répertoire des scripts d'admin
346 richard 22
DIR_ETC="/usr/local/etc"			# répertoire des fichiers de conf
628 richard 23
CONF_FILE="$DIR_ETC/alcasar.conf"		# main alcasar conf file
510 richard 24
VERSION="/var/www/html/VERSION"			# contient la version en cours
1469 richard 25
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2`	# EXTernal InterFace
26
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`	# INTernal InterFace
1890 franck 27
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
28
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
29
INT_DNS_mode=`grep ^INT_DNS_ACTIVE= $CONF_FILE|cut -d"=" -f2`
30
LDAP_mode=`grep ^LDAP= $CONF_FILE|cut -d"=" -f2`
628 richard 31
HOSTNAME="alcasar"
369 richard 32
DB_USER="radius"
504 richard 33
radiuspwd=""
384 richard 34
SED="/bin/sed -i"
510 richard 35
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
36
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
37
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
38
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
1564 richard 39
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2` 2>/dev/null
923 franck 40
DOMAIN=${DOMAIN:=localdomain}
628 richard 41
DATE=`date '+%d %B %Y - %Hh%M'`
42
private_network_calc ()
43
{
1060 richard 44
	PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2`				# prefixe du réseau (ex. 24)
45
	PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2`				# @ réseau de consultation (ex.: 192.168.182.0)
46
	PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX							# @ + masque du réseau de consult (192.168.182.0/24)
628 richard 47
	classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2`		# classes de réseau (ex.: 2=classe B, 3=classe C)
1060 richard 48
	PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`.					# @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
49
	PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2`				# private network broadcast (ie.: 192.168.182.255)
50
	private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup`				# last octet of LAN address
51
	private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup`				# last octet of LAN broadcast
52
	PRIVATE_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 1`		# First network address (ex.: 192.168.182.1)
53
	PRIVATE_SECOND_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 2`	# second network address (ex.: 192.168.182.2)
54
	PRIVATE_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1`	# last network address (ex.: 192.168.182.254)
1581 richard 55
	PRIVATE_MAC=`/sbin/ip link show $INTIF | grep ether | cut -d" " -f6| sed 's/:/-/g'| awk '{print toupper($0)}'`	# MAC address of INTIF
628 richard 56
}
8 franck 57
 
933 franck 58
usage="Usage: alcasar-conf.sh {--create or -create} | {--load or -load} | {--apply or -apply}"
8 franck 59
nb_args=$#
60
args=$1
61
if [ $nb_args -eq 0 ]
62
then
1890 franck 63
	nb_args=100:26:6C:
8 franck 64
	args="-h"
65
fi
66
case $args in
67
	-\? | -h* | --h*)
68
		echo "$usage"
69
		exit 0
70
		;;
389 franck 71
	--create|-create)	
8 franck 72
		[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
73
		mkdir $DIR_UPDATE
1758 richard 74
# backup the users database
1827 raphael.pi 75
		$DIR_BIN/alcasar-mysql.sh -dump
1777 richard 76
		cp /var/Save/base/`ls -1t /var/Save/base|head -1` $DIR_UPDATE
1758 richard 77
# backup the logo
8 franck 78
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
1758 richard 79
# backup Dansguardian files
310 richard 80
		cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
879 richard 81
		cp -f /etc/dansguardian/lists/urlregexplist $DIR_UPDATE
310 richard 82
		cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
83
		cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE
84
		cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE
85
		cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE
86
		cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
1758 richard 87
# backup of different conf files (main conf file, filtering, digest, etc)
8 franck 88
		mkdir $DIR_UPDATE/etc/
346 richard 89
		cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
1758 richard 90
# backup of the security certificates (server & CA)
91
		cp -f /etc/pki/tls/certs/alcasar.crt* $DIR_UPDATE # autosigned and official if exist
92
		cp -f /etc/pki/tls/private/alcasar.key* $DIR_UPDATE # autosigned & official if exist
1564 richard 93
		cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
94
		cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
95
		if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
96
			cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
510 richard 97
		else
1564 richard 98
			cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
510 richard 99
		fi
1758 richard 100
# backup DNSMASQ conf file
933 franck 101
	 	cp /etc/sysconfig/dnsmasq $DIR_UPDATE
1758 richard 102
# archive file creation
8 franck 103
		cd /tmp
104
		tar -cf alcasar-conf.tar conf/
105
		gzip -f alcasar-conf.tar
106
		rm -rf $DIR_UPDATE
107
		;;
389 franck 108
	--load|-load)
8 franck 109
		cd /tmp
1057 richard 110
		tar -xf /tmp/alcasar-conf*.tar.gz
1060 richard 111
# Retrieve the logo
510 richard 112
		[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
8 franck 113
		chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
1060 richard 114
# Retrieve the security certificates (CA and server)
1758 richard 115
		cp -f $DIR_UPDATE/alcasar-ca.crt* /etc/pki/CA/ # autosigned & official
116
		cp -f $DIR_UPDATE/alcasar-ca.key* /etc/pki/CA/private/ # autosigned & official
117
		cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
118
		cp -f $DIR_UPDATE/alcasar.key /etc/pki/tls/private/
675 richard 119
		[ -e $DIR_UPDATE/server-chain.crt ] &&	cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
8 franck 120
		chown -R root:apache /etc/pki
121
		chmod -R 750 /etc/pki
1060 richard 122
# Import of the users database
1671 richard 123
		gzip -dc < `ls $DIR_UPDATE/alcasar-users-database*` | mysql -u$DB_USER -p$radiuspwd
1760 richard 124
# Retrieve local parameters & 
125
	# !!! for this version (2.9.2) we need to create new digest accounts and Remove blacklist files (now in /usr/local/share)
126
	# !!! remove the first two lines for future versions
127
		[ -d $DIR_UPDATE/etc ] && rm -rf $DIR_UPDATE/etc/alcasar-dnsfilter*
1866 franck 128
		[ -d $DIR_UPDATE/etc ] && rm -f $DIR_UPDATE/etc/digest/*
1760 richard 129
 
130
		[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
1060 richard 131
# Retrieve Dansguardian files
1758 richard 132
		cp -f $DIR_UPDATE/exceptioniplist /etc/dansguardian/lists/
133
		cp -f $DIR_UPDATE/exceptionsitelist /etc/dansguardian/lists/
134
		cp -f $DIR_UPDATE/urlregexplist /etc/dansguardian/lists/
135
		cp -f $DIR_UPDATE/bannedsitelist /etc/dansguardian/lists/ 
136
		cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
137
		cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
138
		cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
8 franck 139
		chown -R dansguardian:apache /etc/dansguardian/lists
140
		chmod -R g+rw /etc/dansguardian/lists
1060 richard 141
# Adapt DNS/URL filtering
142
		PARENT_SCRIPT=`basename $0`
637 richard 143
		export PARENT_SCRIPT
1827 raphael.pi 144
		$DIR_BIN/alcasar-bl.sh -adapt
145
		$DIR_BIN/alcasar-bl.sh -reload
1060 richard 146
# retrieve dnsmasq general config file
147
		[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq \
148
		&& chown root.root /etc/sysconfig/dnsmasq \
149
		&& chmod 644 /etc/sysconfig/dnsmasq
150
# admin profile update (admin + manager + backup)
1827 raphael.pi 151
		$DIR_BIN/alcasar-profil.sh --list
634 richard 152
# Start / Stop SSH Daemon
1065 richard 153
		ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
634 richard 154
		if [ $ssh_active = "on" ]
155
		then
1574 richard 156
			/usr/bin/systemctl -q enable sshd.service
634 richard 157
		else
1574 richard 158
			/usr/bin/systemctl -q disable sshd.service
634 richard 159
		fi
1758 richard 160
# modifications added with this version (2.9.2)
161
		# add "HOSTNAME=" in alcasar.conf
162
		hostname_defined=`grep ^HOSTNAME= $CONF_FILE|wc -l`
1759 richard 163
		if [ $hostname_defined = "0" ]
1758 richard 164
		then
165
			$SED "/^DOMAIN=/iHOSTNAME=alcasar" $CONF_FILE
166
		fi
1060 richard 167
# Remove the update folder
8 franck 168
		rm -rf $DIR_UPDATE
169
		;;
628 richard 170
	--apply|-apply)
994 franck 171
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
1054 franck 172
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
628 richard 173
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
174
		if [[ "$?" -ne 0 ]]
175
		then 
176
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
177
			exit 0
178
		fi
1054 franck 179
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
1590 richard 180
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
1585 richard 181
		if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
182
		then
183
			PUBLIC_GATEWAY="dhcp"
1590 richard 184
 
1585 richard 185
		else
186
			check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
187
			if [[ "$?" -ne 0 ]]
628 richard 188
			then 
1585 richard 189
				echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
190
				exit 0
191
			fi
1590 richard 192
			PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
193
			PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
1585 richard 194
			PUBLIC_GATEWAY=`grep ^GW $CONF_FILE|cut -d"=" -f2`
195
			check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
196
			if [[ "$?" -ne 0 ]]
197
			then 
198
				echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
199
				exit 0
200
			fi
628 richard 201
		fi
1590 richard 202
		DNS1=`grep ^DNS1 $CONF_FILE|cut -d"=" -f2`
203
		check=$(echo $DNS1 | egrep $PTN)
204
		if [[ "$?" -ne 0 ]]
205
		then 
206
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
207
			exit 0
208
		fi
209
		DNS2=`grep ^DNS2 $CONF_FILE|cut -d"=" -f2`
210
		check=$(echo $DNS2 | egrep $PTN)
211
		if [[ "$?" -ne 0 ]]
212
		then 
213
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
214
			exit 0
215
		fi
631 richard 216
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
632 richard 217
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
628 richard 218
		private_network_calc
632 richard 219
		INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
220
		ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
923 franck 221
 		DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
862 richard 222
		DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
1060 richard 223
		if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
933 franck 224
		then
1890 franck 225
			if [ $DHCP_mode = "off" ] || [ $DHCP_mode = "Off" ] || [ $DHCP_mode = "OFF" ]
1060 richard 226
			then
1827 raphael.pi 227
				$DIR_BIN/alcasar-dhcp.sh --off
1890 franck 228
			else
229
			        $DIR_BIN/alcasar-dhcp.sh --on
1060 richard 230
			fi
1806 franck 231
 
232
# Implementation of the local DNS
1890 franck 233
			if [ $INT_DNS_mode = "on" ] || [ $INT_DNS_mode = "On" ] || [ $INT_DNS_mode = "ON" ]
234
			then
235
				$DIR_BIN/alcasar-dns-local.sh --on
236
			else
237
				$DIR_BIN/alcasar-dns-local.sh --off
238
			fi
1806 franck 239
 
1694 franck 240
# Implementation of the authentification LDAP
1890 franck 241
#			if [ LDAP_mode = "on" ] || [ $LDAP_mode = "On" ] || [ $LDAP_mode = "ON" ]
242
#			then
243
#				$DIR_BIN/alcasar-ldap.sh
244
#			fi
1611 franck 245
 
1585 richard 246
# Logout everybody
1827 raphael.pi 247
			$DIR_BIN/alcasar-logout.sh all		
1585 richard 248
# Services stop
1521 richard 249
			echo -n "Stop services : "
1850 franck 250
			for i in ntpd tinyproxy dnsmasq dnsmasq-whitelist dnsmasq-blacklist dnsmasq-blackhole chilli network
1060 richard 251
			do
1574 richard 252
				/usr/bin/systemctl stop $i && echo -n "$i, "
1060 richard 253
			done
1827 raphael.pi 254
			/usr/bin/kill -s SIGSTOP $(pidof httpd)
1521 richard 255
			echo
1060 richard 256
		fi
628 richard 257
 
258
# /etc/hosts
1583 richard 259
		$SED "/alcasar/s?.*?$PRIVATE_IP\talcasar alcasar.localdomain?g" /etc/hosts
1518 richard 260
# EXTIF config
1585 richard 261
		if [ $PUBLIC_IP_MASK == "dhcp" ]
262
		then
263
			cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
264
DEVICE=$EXTIF
265
BOOTPROTO=dhcp
266
DNS1=127.0.0.1
267
PEERDNS=no
268
RESOLV_MODS=yes
269
ONBOOT=yes
270
METRIC=10
271
MII_NOT_SUPPORTED=yes
272
IPV6INIT=no
273
IPV6TO4INIT=no
274
ACCOUNTING=no
275
USERCTL=no
276
MTU=$MTU
1850 franck 277
NOZEROCONF=yes
1585 richard 278
EOF
279
		else	
280
			cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
281
DEVICE=$EXTIF
282
BOOTPROTO=static
283
IPADDR=$PUBLIC_IP
284
NETMASK=$PUBLIC_NETMASK
285
GATEWAY=$PUBLIC_GATEWAY
286
DNS1=127.0.0.1
287
RESOLV_MODS=yes
288
ONBOOT=yes
289
METRIC=10
290
MII_NOT_SUPPORTED=yes
291
IPV6INIT=no
292
IPV6TO4INIT=no
293
ACCOUNTING=no
294
USERCTL=no
295
MTU=$MTU
1850 franck 296
NOZEROCONF=yes
1585 richard 297
EOF
298
		fi
1518 richard 299
# INTIF config (for bypass mode only)
1554 richard 300
		$SED "s?^IPADDR=.*?IPADDR=$PRIVATE_IP?" /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
301
		$SED "s?^NETMASK=.*?NETMASK=$PRIVATE_NETMASK?" /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
628 richard 302
# NTP server
632 richard 303
		$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
628 richard 304
# host.allow 
305
		cat <<EOF > /etc/hosts.allow
306
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
307
sshd: ALL
308
ntpd: $PRIVATE_NETWORK_SHORT
309
EOF
632 richard 310
# Alcasar Control Center
634 richard 311
		$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
1419 richard 312
		FIC_MOD_SSL=`find /etc/httpd/conf/ -type f -name ssl.conf`
634 richard 313
		$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
314
		$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
632 richard 315
# Dialup_Admin
634 richard 316
		$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
317
		$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
632 richard 318
# coova
634 richard 319
		$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
320
		$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
321
		$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
322
		$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
1581 richard 323
		# modify the DHCP static ip file. Reserve the second IP address for INTIF (the first one is for tun0). Keep previous entries
324
		$SED "s?^$PRIVATE_MAC.*?$PRIVATE_MAC $PRIVATE_SECOND_IP?" $DIR_ETC/alcasar-ethers
632 richard 325
# dnsmasq
1795 franck 326
		$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blacklist.conf /etc/dnsmasq-whitelist.conf /etc/dnsmasq-blackhole.conf
1377 richard 327
		for i in /etc/dnsmasq.conf /etc/dnsmasq-blacklist.conf
673 richard 328
		do
329
			$SED "/^server=/d" $i
330
			echo "server=$DNS1" >> $i
331
			echo "server=$DNS2" >> $i
332
		done
1060 richard 333
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
634 richard 334
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
1518 richard 335
# tinyproxy			
336
		$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
634 richard 337
# DG + BL
338
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
339
# Watchdog
340
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
341
# Prompts
342
		$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
343
# sudoers
344
		$SED "s?^Host_Alias.*?Host_Alias	LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost		#réseau de l'organisme?g" /etc/sudoers
1060 richard 345
		if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
346
		then
634 richard 347
# Services start
1574 richard 348
			/usr/bin/systemctl start network && echo -n "Start service : network" && sleep 1
1827 raphael.pi 349
			$DIR_BIN/alcasar-dhcp.sh -$DHCP_mode && echo -n ", coova" # apply DHCP mode and start coova
350
			for i in dnsmasq tinyproxy ntpd
1521 richard 351
				do
352
					sleep 1
1574 richard 353
					/usr/bin/systemctl start $i && echo -n ", $i"
1521 richard 354
				done
1827 raphael.pi 355
			$DIR_BIN/alcasar-bl.sh -reload && echo ", dnsmasq-blacklist, dnsmasq-whitelist, iptables,"
356
			/usr/bin/kill -s SIGCONT $(pidof httpd)
357
			/usr/bin/systemctl reload httpd && echo -n ", httpd"
1060 richard 358
		fi
628 richard 359
# Start / Stop SSH Daemon
1065 richard 360
		ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
634 richard 361
		if [ $ssh_active = "on" ]
362
		then
1574 richard 363
			/usr/bin/systemctl enable sshd.service
1060 richard 364
			if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
365
			then
1574 richard 366
				/usr/bin/systemctl start sshd.service
1060 richard 367
			fi
634 richard 368
		else
1574 richard 369
			/usr/bin/systemctl disable sshd.service
1060 richard 370
			if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
371
			then
1574 richard 372
				/usr/bin/systemctl stop sshd.service
1060 richard 373
			fi
634 richard 374
		fi
628 richard 375
		;;
8 franck 376
	*)
377
		echo "Argument inconnu :$1";
378
		echo "$usage"
379
		exit 1
380
		;;
381
esac
382