Subversion Repositories ALCASAR

Rev

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

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