PageRenderTime 97ms CodeModel.GetById 94ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/ppp/ip-up.d/0000usepeerdns

http://github.com/brinkman83/bashrc
Shell | 33 lines | 16 code | 9 blank | 8 comment | 6 complexity | 47b1eee2bd4e9e492ad5a9f5870ca272 MD5 | raw file
 1#!/bin/sh -e
 2
 3# this variable is only set if the usepeerdns pppd option is being used
 4[ "$USEPEERDNS" ] || exit 0
 5
 6# exit if the resolvconf package is installed
 7[ -x /sbin/resolvconf ] && exit 0
 8
 9# create the file if it does not exist
10if [ ! -e /etc/resolv.conf ]; then
11  : > /etc/resolv.conf
12fi
13
14# follow any symlink to find the real file
15REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)
16
17# merge the new nameservers with the other options from the old configuration
18{
19  cat /etc/ppp/resolv.conf
20  grep --invert-match '^nameserver[[:space:]]' "$REALRESOLVCONF" || true
21} > "$REALRESOLVCONF.tmp"
22
23# backup the old configuration and install the new one
24cp -a "$REALRESOLVCONF" "$REALRESOLVCONF.pppd-backup"
25mv -f "$REALRESOLVCONF.tmp" "$REALRESOLVCONF"
26
27# restart nscd because resolv.conf has changed
28if [ -e /var/run/nscd.pid ]; then
29  /etc/init.d/nscd restart || true
30fi
31
32exit 0
33