Subversion Repositories ALCASAR

Rev

Rev 2432 | Rev 2488 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2432 Rev 2474
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-conf.sh 2432 2017-10-22 20:56:33Z richard $
2
# $Id: alcasar-conf.sh 2474 2017-12-30 02:00:04Z 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
 
Line 37... Line 37...
37
SED="/bin/sed -i"
37
SED="/bin/sed -i"
38
RUNNING_VERSION=`grep ^VERSION= $CONF_FILE|cut -d'=' -f2`
38
RUNNING_VERSION=`grep ^VERSION= $CONF_FILE|cut -d'=' -f2`
39
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
39
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
40
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
40
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
41
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
41
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
42
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` 			# server DNS1 (for WL domain names)
42
DNS1=`grep ^DNS1= $CONF_FILE | cut -d'=' -f2` 			# server DNS1 (for WL domain names)
43
DOMAIN=${DOMAIN:=localdomain}
43
DOMAIN=${DOMAIN:=localdomain}
44
DATE=`date '+%d %B %Y - %Hh%M'`
44
DATE=`date '+%d %B %Y - %Hh%M'`
45
 
45
 
46
private_network_calc ()
46
private_network_calc ()
47
{
47
{
Line 173... Line 173...
173
			echo "HTTPS_CHILLI=off" >> $CONF_FILE
173
			echo "HTTPS_CHILLI=off" >> $CONF_FILE
174
		fi
174
		fi
175
		;;
175
		;;
176
	--apply|-apply)
176
	--apply|-apply)
177
		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"
177
		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"
178
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
178
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
179
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
179
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
180
		if [[ "$?" -ne 0 ]]
180
		if [[ "$?" -ne 0 ]]
181
		then 
181
		then 
182
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
182
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
183
			exit 0
183
			exit 0
184
		fi
184
		fi
185
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
185
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2`
186
		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"
186
		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"
187
		if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
187
		if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
188
		then
188
		then
189
			PUBLIC_GATEWAY="dhcp"
189
			PUBLIC_GATEWAY="dhcp"
190
 
190
 
Line 195... Line 195...
195
				echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
195
				echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
196
				exit 0
196
				exit 0
197
			fi
197
			fi
198
			PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
198
			PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
199
			PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
199
			PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
200
			PUBLIC_GATEWAY=`grep ^GW $CONF_FILE|cut -d"=" -f2`
200
			PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2`
201
			check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
201
			check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
202
			if [[ "$?" -ne 0 ]]
202
			if [[ "$?" -ne 0 ]]
203
			then 
203
			then 
204
				echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
204
				echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
205
				exit 0
205
				exit 0
206
			fi
206
			fi
207
		fi
207
		fi
208
		DNS1=`grep ^DNS1 $CONF_FILE|cut -d"=" -f2`
208
		DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
209
		check=$(echo $DNS1 | egrep $PTN)
209
		check=$(echo $DNS1 | egrep $PTN)
210
		if [[ "$?" -ne 0 ]]
210
		if [[ "$?" -ne 0 ]]
211
		then 
211
		then 
212
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
212
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
213
			exit 0
213
			exit 0
214
		fi
214
		fi
215
		DNS2=`grep ^DNS2 $CONF_FILE|cut -d"=" -f2`
215
		DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
216
		check=$(echo $DNS2 | egrep $PTN)
216
		check=$(echo $DNS2 | egrep $PTN)
217
		if [[ "$?" -ne 0 ]]
217
		if [[ "$?" -ne 0 ]]
218
		then 
218
		then 
219
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
219
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
220
			exit 0
220
			exit 0
221
		fi
221
		fi
222
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
222
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
223
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
223
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
224
		private_network_calc
224
		private_network_calc
225
		INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
225
		INSTALL_DATE=`grep ^INSTALL_DATE= $CONF_FILE|cut -d"=" -f2`
226
		ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
226
		ORGANISME=`grep ^ORGANISM= $CONF_FILE|cut -d"=" -f2-`
227
		DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
227
		DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
228
		if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
228
		if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
229
		then
229
		then
230
			if [ $DHCP_mode = "off" ] || [ $DHCP_mode = "Off" ] || [ $DHCP_mode = "OFF" ]
230
			if [ $DHCP_mode = "off" ] || [ $DHCP_mode = "Off" ] || [ $DHCP_mode = "OFF" ]
231
			then
231
			then
232
				$DIR_BIN/alcasar-dhcp.sh --off
232
				$DIR_BIN/alcasar-dhcp.sh --off
Line 386... Line 386...
386
			$DIR_BIN/alcasar-bl.sh -reload && echo -n ", dnsmasq-blacklist, dnsmasq-whitelist, iptables"
386
			$DIR_BIN/alcasar-bl.sh -reload && echo -n ", dnsmasq-blacklist, dnsmasq-whitelist, iptables"
387
			/usr/bin/kill -s SIGCONT $(pidof httpd)
387
			/usr/bin/kill -s SIGCONT $(pidof httpd)
388
			/usr/bin/systemctl reload httpd && echo -n ", httpd"
388
			/usr/bin/systemctl reload httpd && echo -n ", httpd"
389
		fi
389
		fi
390
# Start / Stop SSH Daemon
390
# Start / Stop SSH Daemon
391
		ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
391
		ssh_active=`grep ^SSH= $CONF_FILE|cut -d"=" -f2`
392
		if [ $ssh_active = "on" ]
392
		if [ $ssh_active = "on" ]
393
		then
393
		then
394
			/usr/bin/systemctl enable sshd.service
394
			/usr/bin/systemctl enable sshd.service
395
			if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
395
			if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
396
			then
396
			then