204,15 → 204,14 |
## Configure ALCASAR according to alcasar.conf ## |
#################################################### |
--apply|-apply) |
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" |
PTN='^\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\)/[012]\?[[:digit:]]$' |
PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2` |
if ! echo $PRIVATE_IP_MASK | grep -q -E $PTN |
if [[ $(expr "$PRIVATE_IP_MASK" : $PTN) -eq 0 ]] |
then |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)" |
exit 0 |
fi |
PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2` |
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" |
if [[ "$PUBLIC_IP_MASK" == "dhcp" ]] |
then |
PUBLIC_GATEWAY="dhcp" |
220,7 → 219,7 |
DNS1=`echo $DHCP_DNS_servers | cut -d"," -f1` |
DNS2=`echo $DHCP_DNS_servers | cut -d"," -f2` |
else |
if ! echo $PUBLIC_IP_MASK | grep -q -E $PTN |
if [[ $(expr "$PUBLIC_IP_MASK" : $PTN) -eq 0 ]] |
then |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)" |
exit 0 |
228,19 → 227,20 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1` |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2` |
PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2` |
if ! echo $PUBLIC_GATEWAY | grep -q -E $PTN |
PTN='^\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\)$' |
if [[ $(expr "$PUBLIC_GATEWAY" : $PTN) -eq 0 ]] |
then |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)" |
exit 0 |
fi |
DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2` |
if ! echo $DNS1 | grep -q -E $PTN |
if [[ $(expr "$DNS1" : $PTN) -eq 0 ]] |
then |
echo "Syntax error for the IP address of the first DNS server ($DNS1)" |
exit 0 |
fi |
DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2` |
if ! echo $DNS2 | grep -q -E $PTN |
if [[ $(expr "$DNS2" : $PTN) -eq 0 ]] |
then |
echo "Syntax error for the IP address of the second DNS server ($DNS2)" |
exit 0 |