Subversion Repositories ALCASAR

Rev

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

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