#!/bin/bash # $HeadURL$ $LastChangedRevision$ set -e PROGNAME=$(basename $0) # Load support functions . $(pcms-config PCMS_SHARE_PREFIX)/scripts/support.sh main() { # Defaults for options VERBOSELEVEL=2 OPT_FILE=/etc/resolv.conf OPT_TOUCH=false # Process options while [ $# -ge 1 ]; do case $1 in --file=*) OPT_FILE=${1#*=} ;; --touch) OPT_TOUCH=true ;; --debug=*) VERBOSELEVEL=${1#*=} ;; -d) VERBOSELEVEL=$2; shift ;; -v|--verbose) VERBOSELEVEL=3 ;; --) shift; break ;; -*) error "main: $1: bad option" ;; *) break ;; esac shift done # Process arguments [ $# = 1 ] || usage eval set -- $(encode --decode "$1") [ $# = 1 -o $# = 2 ] || usage NAME_SERVERS=$1 SEARCH_DOMAINS=$2 debug 10 "dns_static: NAME_SERVERS=\"$NAME_SERVERS\", SEARCH_DOMAINS=\"$SEARCH_DOMAINS\"" # Guts { for NAME_SERVER in $NAME_SERVERS; do echo "nameserver $NAME_SERVER" done [ "X$SEARCH_DOMAINS" = X ] || echo "search $SEARCH_DOMAINS" } > $OPT_FILE # OPT_TOUCH handling not needed; the file is *always* touched by the above code. } usage() { echo "Usage: $PROGNAME [ --file= ] [@....][@...]" >&2; exit 1; } main "$@"