Project

General

Profile

« Previous | Next » 

Revision 1702a838

Added by Renato Botelho almost 12 years ago

Improve sh syntax using ${} for all variables

View differences:

usr/local/sbin/ppp-linkup
1 1
#!/bin/sh
2 2

  
3
if [ "$2" == "inet" ]; then
3
if [ "${2}" == "inet" ]; then
4 4

  
5 5
	OLD_ROUTER=`/bin/cat /tmp/${1}_router`
6 6
	if [ "${OLD_ROUTER}" != "" ]; then
7 7
		echo "Removing states to old router ${OLD_ROUTER}" | logger -t ppp-linkup
8
		/sbin/pfctl -i $1 -k 0.0.0.0/0 -k ${OLD_ROUTER}/32
9
		/sbin/pfctl -i $1 -k ${OLD_ROUTER}/32 -k 0.0.0.0/0
8
		/sbin/pfctl -i ${1} -k 0.0.0.0/0 -k ${OLD_ROUTER}/32
9
		/sbin/pfctl -i ${1} -k ${OLD_ROUTER}/32 -k 0.0.0.0/0
10 10
	fi
11 11

  
12 12
	# let the configuration system know that the ipv4 has changed.
13
	/bin/echo $4 > /tmp/$1_router
14
	/bin/echo $3 > /tmp/$1_ip
15
	/usr/bin/touch /tmp/$1up
13
	/bin/echo ${4} > /tmp/${1}_router
14
	/bin/echo ${3} > /tmp/${1}_ip
15
	/usr/bin/touch /tmp/${1}up
16 16

  
17 17
	ALLOWOVERRIDE=`/usr/bin/grep -c dnsallowoverride /conf/config.xml`
18
	if [ $ALLOWOVERRIDE -gt 0 ]; then
18
	if [ ${ALLOWOVERRIDE} -gt 0 ]; then
19 19
		# write nameservers to file
20
		if [ "`echo $6|grep -c dns1`" -gt 0 ]; then
21
			DNS1=`echo $6 |awk '{print $2}'`
22
			echo "$DNS1"> /var/etc/nameserver_$1
23
			/sbin/route change "$DNS1" $4
20
		if [ "`echo ${6}|grep -c dns1`" -gt 0 ]; then
21
			DNS1=`echo ${6} |awk '{print ${2}}'`
22
			echo "${DNS1}"> /var/etc/nameserver_${1}
23
			/sbin/route change "${DNS1}" ${4}
24 24
		fi
25
		if [ "`echo $7|grep -c dns2`" -gt 0 ]; then
26
			DNS2=`echo $7 |awk '{print $2}'`
27
			echo "$DNS2" >> /var/etc/nameserver_$1
28
			/sbin/route change "$DNS2" $4
25
		if [ "`echo ${7}|grep -c dns2`" -gt 0 ]; then
26
			DNS2=`echo ${7} |awk '{print ${2}}'`
27
			echo "${DNS2}" >> /var/etc/nameserver_${1}
28
			/sbin/route change "${DNS2}" ${4}
29 29
		fi
30 30
		/usr/local/sbin/pfSctl -c 'service reload dns'
31 31
		/bin/sleep 1
32 32
	fi
33 33
fi
34 34

  
35
if [ "$2" == "inet6" ]; then
35
if [ "${2}" == "inet6" ]; then
36 36
	# let the configuration system know that the ipv6 has changed.
37
	/bin/echo $4 |cut -d% -f1 > /tmp/$1_routerv6
38
	/bin/echo $3 |cut -d% -f1 > /tmp/$1_ipv6
39
	/usr/bin/touch /tmp/$1upv6
37
	/bin/echo ${4} |cut -d% -f1 > /tmp/${1}_routerv6
38
	/bin/echo ${3} |cut -d% -f1 > /tmp/${1}_ipv6
39
	/usr/bin/touch /tmp/${1}upv6
40 40

  
41 41
	ALLOWOVERRIDE=`/usr/bin/grep -c dnsallowoverride /conf/config.xml`
42
	if [ $ALLOWOVERRIDE -gt 0 ]; then
42
	if [ ${ALLOWOVERRIDE} -gt 0 ]; then
43 43
		# write nameservers to file
44
		if [ "`echo $6|grep -c dns1`" -gt 0 ]; then
45
			DNS1=`echo $6 |awk '{print $2}'`
46
			echo "$DNS1"> /var/etc/nameserver_v6$1
47
			/sbin/route change -inet6 "$DNS1" $4
44
		if [ "`echo ${6}|grep -c dns1`" -gt 0 ]; then
45
			DNS1=`echo ${6} |awk '{print ${2}}'`
46
			echo "${DNS1}"> /var/etc/nameserver_v6${1}
47
			/sbin/route change -inet6 "${DNS1}" ${4}
48 48
		fi
49
		if [ "`echo $7|grep -c dns2`" -gt 0 ]; then
50
			DNS2=`echo $7 |awk '{print $2}'`
51
			echo "$DNS2" >> /var/etc/nameserver_v6$1
52
			/sbin/route change -inet6 "$DNS2" $4
49
		if [ "`echo ${7}|grep -c dns2`" -gt 0 ]; then
50
			DNS2=`echo ${7} |awk '{print ${2}}'`
51
			echo "${DNS2}" >> /var/etc/nameserver_v6${1}
52
			/sbin/route change -inet6 "${DNS2}" ${4}
53 53
		fi
54 54
		/usr/local/sbin/pfSctl -c 'service reload dns'
55 55
		/bin/sleep 1
56 56
	fi
57 57
fi
58 58

  
59
/usr/local/sbin/pfSctl -c "interface newip $1"
59
/usr/local/sbin/pfSctl -c "interface newip ${1}"
60 60
exit 0

Also available in: Unified diff