Subversion Repositories ALCASAR

Rev

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

Rev 3170 Rev 3190
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-conf.sh 3170 2024-02-22 17:28:40Z rexy $
2
# $Id: alcasar-conf.sh 3190 2024-04-07 22:35:03Z rexy $
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 210... Line 210...
210
##   Configure ALCASAR according to alcasar.conf  ##
210
##   Configure ALCASAR according to alcasar.conf  ##
211
####################################################
211
####################################################
212
	--apply|-apply)
212
	--apply|-apply)
213
		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"
213
		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"
214
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
214
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
215
		if ! echo $PRIVATE_IP_MASK | egrep -q $PTN
215
		if ! echo $PRIVATE_IP_MASK | grep -q -E $PTN
216
		then
216
		then
217
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
217
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
218
			exit 0
218
			exit 0
219
		fi
219
		fi
220
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2`
220
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2`
Line 224... Line 224...
224
			PUBLIC_GATEWAY="dhcp"
224
			PUBLIC_GATEWAY="dhcp"
225
			DHCP_DNS_servers=`cat /var/lib/dhclient/dhclient--$EXTIF.lease |grep domain-name-servers|sed -n "1 p"| rev|cut -d" " -f1|rev|tr -d ';'`
225
			DHCP_DNS_servers=`cat /var/lib/dhclient/dhclient--$EXTIF.lease |grep domain-name-servers|sed -n "1 p"| rev|cut -d" " -f1|rev|tr -d ';'`
226
			DNS1=`echo $DHCP_DNS_servers | cut -d"," -f1`
226
			DNS1=`echo $DHCP_DNS_servers | cut -d"," -f1`
227
			DNS2=`echo $DHCP_DNS_servers | cut -d"," -f2`
227
			DNS2=`echo $DHCP_DNS_servers | cut -d"," -f2`
228
		else
228
		else
229
			if ! echo $PUBLIC_IP_MASK | egrep -q $PTN
229
			if ! echo $PUBLIC_IP_MASK | grep -q -E $PTN
230
			then
230
			then
231
				echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
231
				echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
232
				exit 0
232
				exit 0
233
			fi
233
			fi
234
			PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
234
			PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
235
			PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
235
			PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
236
			PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2`
236
			PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2`
237
			if ! echo $PUBLIC_GATEWAY | egrep -q $PTN
237
			if ! echo $PUBLIC_GATEWAY | grep -q -E $PTN
238
			then
238
			then
239
				echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
239
				echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
240
				exit 0
240
				exit 0
241
			fi
241
			fi
242
			DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
242
			DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
243
			if ! echo $DNS1 | egrep -q $PTN
243
			if ! echo $DNS1 | grep -q -E $PTN
244
			then
244
			then
245
				echo "Syntax error for the IP address of the first DNS server ($DNS1)"
245
				echo "Syntax error for the IP address of the first DNS server ($DNS1)"
246
				exit 0
246
				exit 0
247
			fi
247
			fi
248
			DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
248
			DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
249
			if ! echo $DNS2 | egrep -q $PTN
249
			if ! echo $DNS2 | grep -q -E $PTN
250
			then
250
			then
251
				echo "Syntax error for the IP address of the second DNS server ($DNS2)"
251
				echo "Syntax error for the IP address of the second DNS server ($DNS2)"
252
				exit 0
252
				exit 0
253
			fi
253
			fi
254
		fi
254
		fi