scripts

random scripts
git clone git://parazyd.org/scripts.git
Log | Files | Refs

commit 4f85b36b2cbe91c3af84f0e30ac7b7a9f40ead1f
parent 8e23dcd8d4689cc1faeb478da8e4bfa52f863560
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 10 Nov 2016 21:25:46 +0100

update dn

Diffstat:
Mdn | 57++++++++++++++++++++++++++-------------------------------
1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/dn b/dn @@ -10,39 +10,34 @@ chattr() { esac } -stopd() { - /etc/init.d/unbound stop - /etc/init.d/dnscrypt-proxy stop +use() { + dmn="$1" + srv="$2" + chattr off + /usr/bin/printf "domain %s\nnameserver %s ## %s\n" "$dmn" "$srv" "$dmn"> /etc/resolv.conf + chattr on + if test "$dmn" = out; then + /sbin/service unbound start + /sbin/service dnscrypt-proxy start + else + /sbin/service unbound stop + /sbin/service dnscrypt-proxy stop + fi } -startd() { - /etc/init.d/unbound start - /etc/init.d/dnscrypt-proxy start -} - -case $1 in - out|o) - startd - chattr off && echo "nameserver 127.0.0.1 # out" > /etc/resolv.conf && chattr on;; - home|h) - stopd - chattr off && echo "nameserver 10.0.1.1 # home" > /etc/resolv.conf && chattr on;; - bridge|b) - stopd - chattr off && echo "nameserver 172.16.17.1 # bridge" > /etc/resolv.conf && chattr on;; - jabba) - stopd - chattr off && echo "nameserver 192.168.43.1 # jabba" > /etc/resolv.conf && chattr on;; - goog|g) - stopd - chattr off && echo "nameserver 8.8.8.8 # google" > /etc/resolv.conf && chattr on;; - me) - stopd - chattr off && echo "nameserver `ip route get 8.8.8.8 | awk '{print $NF; exit}'`" > /etc/resolv.conf && chattr on;; - edit) - chattr off && vim /etc/resolv.conf && chattr on;; +case "$1" in + out|o) use "out" "127.0.0.1";; + home|h) use "multiverse" "10.0.1.1";; + bridge|b) use "bridge" "172.16.17.250";; + goog|g) use "goog" "8.8.8.8";; + dynevpn|dv) use "dyne" "10.8.0.1";; + ti) use "ti" "10.209.20.254";; + edit) chattr on; /usr/bin/vim -u NONE /etc/resolv.conf; chattr off;; + -|off) chattr off;; + +|on) chattr on;; *) - echo "current set as: `awk '{print $4}' /etc/resolv.conf`" - echo "usage: `basename $0` {home|out}" + /usr/bin/printf "current resolv.conf set as:\n" + cat -v /etc/resolv.conf + /usr/bin/printf "\nusage: %s {home|out}\n" "$(basename $0)" exit 1;; esac