| Line 1... |
Line 1... |
| 1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
| 2 |
# $Id: alcasar-conf.sh 3195 2024-04-23 22:39:48Z rexy $
|
2 |
# $Id: alcasar-conf.sh 3201 2024-05-28 17:21:34Z 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 202... |
Line 202... |
| 202 |
|
202 |
|
| 203 |
####################################################
|
203 |
####################################################
|
| 204 |
## Configure ALCASAR according to alcasar.conf ##
|
204 |
## Configure ALCASAR according to alcasar.conf ##
|
| 205 |
####################################################
|
205 |
####################################################
|
| 206 |
--apply|-apply)
|
206 |
--apply|-apply)
|
| 207 |
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"
|
207 |
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:]]$'
|
| 208 |
PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
|
208 |
PRIVATE_IP_MASK=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
|
| 209 |
if ! echo $PRIVATE_IP_MASK | grep -q -E $PTN
|
209 |
if [[ $(expr "$PRIVATE_IP_MASK" : $PTN) -eq 0 ]]
|
| 210 |
then
|
210 |
then
|
| 211 |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
|
211 |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
|
| 212 |
exit 0
|
212 |
exit 0
|
| 213 |
fi
|
213 |
fi
|
| 214 |
PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2`
|
214 |
PUBLIC_IP_MASK=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2`
|
| 215 |
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"
|
- |
|
| 216 |
if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
|
215 |
if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
|
| 217 |
then
|
216 |
then
|
| 218 |
PUBLIC_GATEWAY="dhcp"
|
217 |
PUBLIC_GATEWAY="dhcp"
|
| 219 |
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 ';'`
|
218 |
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 ';'`
|
| 220 |
DNS1=`echo $DHCP_DNS_servers | cut -d"," -f1`
|
219 |
DNS1=`echo $DHCP_DNS_servers | cut -d"," -f1`
|
| 221 |
DNS2=`echo $DHCP_DNS_servers | cut -d"," -f2`
|
220 |
DNS2=`echo $DHCP_DNS_servers | cut -d"," -f2`
|
| 222 |
else
|
221 |
else
|
| 223 |
if ! echo $PUBLIC_IP_MASK | grep -q -E $PTN
|
222 |
if [[ $(expr "$PUBLIC_IP_MASK" : $PTN) -eq 0 ]]
|
| 224 |
then
|
223 |
then
|
| 225 |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
|
224 |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
|
| 226 |
exit 0
|
225 |
exit 0
|
| 227 |
fi
|
226 |
fi
|
| 228 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
227 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
| 229 |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
|
228 |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
|
| 230 |
PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2`
|
229 |
PUBLIC_GATEWAY=`grep ^GW= $CONF_FILE|cut -d"=" -f2`
|
| 231 |
if ! echo $PUBLIC_GATEWAY | grep -q -E $PTN
|
230 |
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]\)$'
|
| - |
|
231 |
if [[ $(expr "$PUBLIC_GATEWAY" : $PTN) -eq 0 ]]
|
| 232 |
then
|
232 |
then
|
| 233 |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
|
233 |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
|
| 234 |
exit 0
|
234 |
exit 0
|
| 235 |
fi
|
235 |
fi
|
| 236 |
DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
|
236 |
DNS1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
|
| 237 |
if ! echo $DNS1 | grep -q -E $PTN
|
237 |
if [[ $(expr "$DNS1" : $PTN) -eq 0 ]]
|
| 238 |
then
|
238 |
then
|
| 239 |
echo "Syntax error for the IP address of the first DNS server ($DNS1)"
|
239 |
echo "Syntax error for the IP address of the first DNS server ($DNS1)"
|
| 240 |
exit 0
|
240 |
exit 0
|
| 241 |
fi
|
241 |
fi
|
| 242 |
DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
|
242 |
DNS2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
|
| 243 |
if ! echo $DNS2 | grep -q -E $PTN
|
243 |
if [[ $(expr "$DNS2" : $PTN) -eq 0 ]]
|
| 244 |
then
|
244 |
then
|
| 245 |
echo "Syntax error for the IP address of the second DNS server ($DNS2)"
|
245 |
echo "Syntax error for the IP address of the second DNS server ($DNS2)"
|
| 246 |
exit 0
|
246 |
exit 0
|
| 247 |
fi
|
247 |
fi
|
| 248 |
fi
|
248 |
fi
|