File: dnssec-trigger-osx.sh.in

package info (click to toggle)
dnssec-trigger 0.13~svn685-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,784 kB
  • ctags: 1,423
  • sloc: ansic: 15,773; sh: 1,788; makefile: 453; xml: 444; objc: 421; python: 334; cpp: 18
file content (41 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!@SHELL@
#
# dnssec trigger for OSX

# the network state has changed, obtain a list of DHCP provided DNS servers.
# somehow in /Library/Preferences/SystemConfiguration/
#   com.apple.network.identification.plist  - list of configs seen
#   preferences.plist - list of what is entered in the config panel
tempfile=/tmp/dnssec-trigger-osx.tmp

# active interfaces
ifs=`ifconfig | awk '/^[^ 	:]*:/ { sub(/:.*$/,empty); iface=$0 } /status: active/ { print iface }'`
ifs=`echo $ifs`

# the ssid(s) of the wifi
ssid=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I 2>&1 | grep "[^B]SSID:"`
bssid=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I 2>&1 | grep "BSSID:"`

# and the DNS servers for that
ips=""
for i in $ifs; do
	ips_i=`ipconfig getpacket $i | grep "domain_name_server" | sed -e 's/^.*{//' -e 's/,/ /g' -e 's/}//' `
	ips="$ips $ips_i"
done
# fix whitespace
ips=`echo $ips`

# see if it has changed
if test -f $tempfile; then
	if echo "$ifs $ips $ssid $bssid" | diff $tempfile - >/dev/null; then
		# it is equal
		#logger "dnssec-trigger(osx) no-change $ifs DNS $ips"
		exit 0
	fi
fi
# store on file
echo "$ifs $ips $ssid $bssid" > $tempfile

logger "dnssec-trigger(osx) detected $ifs DNS $ips"
0sbindir0/dnssec-trigger-control submit "$ips"
exit 0