aboutsummaryrefslogtreecommitdiffstats
path: root/setup-dns.in
diff options
context:
space:
mode:
authorJeff Bilyk <jbilyk@gmail.com>2011-08-07 10:40:43 -0400
committerJeff Bilyk <jbilyk@gmail.com>2011-08-07 10:40:43 -0400
commit1b6c1a0804cffc28620971d0d32ece0074f10894 (patch)
tree1edcc91269ed5a00b546131bba822741f31b100f /setup-dns.in
parent0e82dc7cb5563ce62cbfe3c17cad6ec547c159ac (diff)
downloadalpine-conf-1b6c1a0804cffc28620971d0d32ece0074f10894.tar.bz2
alpine-conf-1b6c1a0804cffc28620971d0d32ece0074f10894.tar.xz
setup-dns: command line options for unattended mode
Diffstat (limited to 'setup-dns.in')
-rwxr-xr-xsetup-dns.in50
1 files changed, 41 insertions, 9 deletions
diff --git a/setup-dns.in b/setup-dns.in
index 02d6cc0..5807a69 100755
--- a/setup-dns.in
+++ b/setup-dns.in
@@ -3,20 +3,52 @@
PREFIX=
. "$PREFIX/lib/libalpine.sh"
-conf="$ROOT/etc/resolv.conf"
+usage() {
+ cat <<__EOF__
+usage: setup-dns [-h] [-d domain name] [-n name server(s)]
+
+Setup /etc/resolv.conf DNS settings
+
+options:
+ -h Show this help
+ -d specify search domain name
+ -n DNS server(s) to use. For multiple servers, surround in quotes and space-seperate the list
+__EOF__
+ exit 1
+}
+
+while getopts "d:n:h" opt; do
+ case $opt in
+ d) DOMAINNAME="$OPTARG";;
+ h) usage;;
+ n) NAMESERVERS="$OPTARG";;
+ esac
+done
+
+conf="/home/jbilyk/alpine-conf/resolv.conf"
+
if [ -f "$conf" ] ; then
domain=`awk '/^domain/ {print $2}' $conf`
dns=`awk '/^nameserver/ {print $2}' $conf`
fi
-echon "DNS domain name? (e.g 'bar.com') [$domain] "
-default_read domain $domain
-echon "DNS nameserver(s)? ["
-for i in $dns ; do
- echon "$i "
-done
-echon "] "
-default_read dns "$dns"
+if [ -n "$DOMAINNAME" ];then
+ domain="$DOMAINNAME"
+else
+ echon "DNS domain name? (e.g 'bar.com') [$domain] "
+ default_read domain $domain
+fi
+
+if [ -n "$NAMESERVERS" ];then
+ dns="$NAMESERVERS"
+else
+ echon "DNS nameserver(s)? ["
+ for i in $dns ; do
+ echon "$i "
+ done
+ echon "] "
+ default_read dns "$dns"
+fi
if [ "$domain" != "" ]; then
echo "search $domain" > $conf