Created
November 28, 2013 19:48
-
-
Save anonymous/7697250 to your computer and use it in GitHub Desktop.
script for in /etc/dhcp/dhclient.d/ to configure dnsmasq via dbus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function inet_aton () { | |
local count=3 | |
local int=0 | |
for num in $(echo $1 | sed -e 's/\./ /g'); do | |
let "int+=$num*256**$count" | |
let "count-=1" | |
done | |
echo $int | |
} | |
if [ "$new_domain_name_servers" ] ; then | |
SetServers=$new_domain_name_servers | |
elif [ "$DHCP4_DOMAIN_NAME_SERVERS" ] ; then | |
SetServers=$DHCP4_DOMAIN_NAME_SERVERS | |
else | |
SetServers="8.8.8.8 8.8.4.4" | |
fi | |
dnsmasq_config() { | |
echo uint32:$(inet_aton $SetServers) > /var/lib/dnsmasq/SetServers | |
dbus-send --system --dest='uk.org.thekelleys.dnsmasq' /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers $(< /var/lib/dnsmasq/SetServers) | |
} | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment