Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # debug:
- export DEBUG=on
- # no debug:
- #unset DEBUG
- dbg_echo () {
- [[ "$DEBUG" ]] && builtin echo $@
- }
- export nameserver=$(cat /proc/net/pnp | grep nameserver | awk '{print $2}')
- if [ -z "${nameserver}" ]; then
- # we have no namersver entry in /proc/net/pnp
- dbg_echo "no nameserver"
- else
- # we do have a nameserver entry in /proc/net/pnp
- dbg_echo "nameserver: ${nameserver}"
- # sysvinit:
- if [ $(pidof /sbin/init) ]; then
- dbg_echo "it's sysvinit"
- # we just make some entry of nameservers in /etc/resolv.conf
- # interface is irrelevant at the moment
- echo "nameserver 192.168.42.254
- nameserver 8.8.8.8
- search res.training" | resolvconf -a dummy.if
- fi
- # systemd:
- if [ $(pidof systemd) ]; then
- dbg_echo "it's systemd"
- dbg_echo "systemd-resolve --interface eth0 --set-dns ${nameserver}"
- systemd-resolve --interface eth0 --set-dns ${nameserver}
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement