Subversion Repositories ALCASAR

Rev

Rev 2274 | Rev 2309 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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