Subversion Repositories ALCASAR

Rev

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