scripts

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

dn (864B)


      1 #!/bin/sh
      2 #
      3 # parazyd - (c) wtfpl 2016
      4 # manage resolv.conf
      5 
      6 chattr() {
      7 	case $1 in
      8 		on)  /usr/bin/chattr -V +i /etc/resolv.conf;;
      9 		off) /usr/bin/chattr -V -i /etc/resolv.conf;;
     10 	esac
     11 }
     12 
     13 use() {
     14 	dmn="$1"
     15 	srv="$2"
     16 	chattr off
     17 	/usr/bin/printf "domain %s\nnameserver %s ## %s\n" "$dmn" "$srv" "$dmn"> /etc/resolv.conf
     18 	chattr on
     19 }
     20 
     21 case "$1" in
     22 	o)     use "out"    "127.0.0.1";;
     23 	h)     use "fq"     "10.66.66.1";;
     24 	b)     use "bridge" "10.11.11.1";;
     25 	g)     use "goog"   "8.8.8.8";;
     26 	dv)    use "dvn"    "10.8.0.1";;
     27 	ti)    use "ti"     "10.209.20.254";;
     28 	lag)   use "lag"    "10.1.1.1";;
     29 	edit)  chattr on; /usr/bin/vim -u NONE /etc/resolv.conf; chattr off;;
     30 	-|off) chattr off;;
     31 	+|on)  chattr on;;
     32 	*)
     33 		/usr/bin/printf "current resolv.conf set as:\n"
     34 		cat -v /etc/resolv.conf
     35 		/usr/bin/printf "\nusage: %s {home|out}\n" "$(basename $0)"
     36 		exit 1;;
     37 esac