Add new adhoc draft script
[khome.git] / home / bin / resolv
1 #! /bin/sh
2
3 FILE='/etc/resolv.conf'
4 CONTENT=\
5 'nameserver 167.206.13.180
6 nameserver 167.206.13.181
7 nameserver 192.168.1.1'
8
9 uncommented() {
10 echo "$CONTENT"
11 }
12
13 commented() {
14 for line in "$CONTENT"
15 do
16 echo "$line" | sed 's/^/#/'
17 done
18 }
19
20 switch_on() {
21 chattr -i "$FILE" # Make mutable
22 rm -f "$FILE"
23 uncommented > "$FILE"
24 chmod a+r "$FILE"
25 }
26
27 switch_off() {
28 rm -f "$FILE"
29 commented > "$FILE"
30 chmod a-rw "$FILE"
31 chattr +i "$FILE" # Make immutable
32 }
33
34 case "$1" in
35 'on' ) switch_on;;
36 'off') switch_off;;
37 '')
38 echo "usage: $0 SWITCH\n\nSWITCH = on | off"
39 exit 1;;
40 esac
This page took 0.080088 seconds and 4 git commands to generate.