~cyphermox/ubuntu/precise/dnsmasq/dbus

« back to all changes in this revision

Viewing changes to debian/resolvconf

  • Committer: Bazaar Package Importer
  • Author(s): Simon Kelley
  • Date: 2005-05-04 13:25:23 UTC
  • mfrom: (0.2.1 upstream) (1.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050504132523-29x9nzdnkypp62nc
Tags: 2.22-2
Make the resolv.conf polling code resistant to 
backwards-moving system clocks. (closes: #306117) (closes: #300694)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Script to update the resolver list for dnsmasq
 
4
#
 
5
# N.B. Resolvconf may run us even if dnsmasq is not running.
 
6
# If dnsmasq is installed then we go ahead and update
 
7
# the resolver list in case dnsmasq is started later.
 
8
#
 
9
# Assumption: On entry, PWD contains the resolv.conf-type files
 
10
#
 
11
# Depends: resolvconf (>= 1.14)
 
12
#
 
13
# Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL.
 
14
#
 
15
# History
 
16
# June 2003 - June 2004: Written by Thomas Hood <jdthood@yahoo.co.uk>
 
17
 
 
18
set -e
 
19
 
 
20
RUN_DIR="/var/run/dnsmasq"
 
21
RSLVRLIST_FILE="${RUN_DIR}/resolv.conf"
 
22
TMP_FILE="${RSLVRLIST_FILE}_new.$$"
 
23
 
 
24
[ -x /usr/sbin/dnsmasq ] || exit 0
 
25
[ -x /lib/resolvconf/list-records ] || exit 1
 
26
 
 
27
PATH=/bin:/sbin
 
28
 
 
29
report_err() { echo "$0: Error: $*" >&2 ; }
 
30
 
 
31
# Stores arguments (minus duplicates) in RSLT, separated by spaces
 
32
# Doesn't work properly if an argument itself contain whitespace
 
33
uniquify()
 
34
{
 
35
        RSLT=""
 
36
        while [ "$1" ] ; do
 
37
                for E in $RSLT ; do
 
38
                        [ "$1" = "$E" ] && { shift ; continue 2 ; }
 
39
                done
 
40
                RSLT="${RSLT:+$RSLT }$1"
 
41
                shift
 
42
        done
 
43
}
 
44
 
 
45
if [ ! -d "$RUN_DIR" ] && ! mkdir --parents --mode=0755 "$RUN_DIR" ; then
 
46
        report_err "Failed trying to create directory $RUN_DIR"
 
47
        exit 1
 
48
fi
 
49
 
 
50
RSLVCNFFILES="$(/lib/resolvconf/list-records | sed -e '/^lo.dnsmasq$/d')"
 
51
 
 
52
NMSRVRS=""
 
53
if [ "$RSLVCNFFILES" ] ; then
 
54
        uniquify $(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]\+//p' $RSLVCNFFILES)
 
55
        NMSRVRS="$RSLT"
 
56
fi
 
57
 
 
58
clean_up() { rm -f "$TMP_FILE" ; }
 
59
trap clean_up EXIT
 
60
: >| "$TMP_FILE"
 
61
for N in $NMSRVRS ; do echo "nameserver $N" >> "$TMP_FILE" ; done
 
62
mv -f "$TMP_FILE" "$RSLVRLIST_FILE"
 
63
 
 
64