#!MARKER_SHELL_CMD PATH=/bin:/usr/bin:/sbin PROGNAME=`basename $0` ############################################################################### # # # NAME SERVICE SWITCHER # # # ############################################################################### ############################################################################### # # Things you should know about this script: # # It is stored under RCS! Keep it that way! If you want a history of # changes made to this script then refer to rlog(1) - don't look here! # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF STARTS HERE # ############################################################################### NAMED_CONF=/etc/named.conf ############################################################################### # # CONFIGURABLE STUFF ENDS HERE # ############################################################################### VERSION="MARKER_PATCHLEVEL" # $Header: /home/ahuxley/dev/arc/ppplc/lib/misc/RCS/nsswitcher.shpp,v 1.5 1999/05/07 14:50:29 alexis Exp $ ############################################################################### # # MAIN FUNCTION (called from very bottom of script) # ############################################################################### main() { ########################################################################### # # PROCESS OPTIONS # ########################################################################### MODE=stopstart PAUSE_PERIOD=0 while [ "X$1" != X ]; do case "$1" in -V) echo "$PROGNAME version $VERSION" exit 0 ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -p) [ "X$2" = X ] && usage PAUSE_PERIOD=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; # '-k' to remain undocumented until bugs fixed - see below -k) MODE=killhup ;; -*) usage ;; *) break ;; esac shift done # Zero args required - only PPPLCD_WANNABE in env is needed. [ "X$1" != X ] && usage [ "X$PPPLCD_WANNABE" = X ] && usage # Are locks required? No. This script should run very quickly. ########################################################################### # # SANITY TESTS # ########################################################################### [ \! -e $NAMED_CONF -o -L $NAMED_CONF ] || error "$NAMED_CONF not symlink" [ -r $NAMED_CONF.local ] || error "$NAMED_CONF.local not accessible" [ -r $NAMED_CONF.inet ] || error "$NAMED_CONF.inet not accessible" ########################################################################### # # GUTS # ########################################################################### case "$PPPLCD_WANNABE" in 0) SWITCHTO=local ;; 1) SWITCHTO=inet ;; *) usage ;; esac info "installing named conf files for $SWITCHTO access" rm -f $NAMED_CONF ln -s $NAMED_CONF.$SWITCHTO $NAMED_CONF if [ $MODE = stopstart ]; then # '/etc/init.d/bind stop' does not reliably stop named under Debian 2.0 info "restarting named" start-stop-daemon --stop --exec /usr/sbin/named [ "X$PAUSE_PERIOD" != X0 ] && sleep $PAUSE_PERIOD start-stop-daemon --start --exec /usr/sbin/named elif [ $SWITCHTO = inet ]; then info "sending SIGHUP to named" kill -HUP `cat /var/run/named.pid` else # SIGHUP fails to unload the known root domain servers. This is # vital to the quick timeouts that local-only config delivers. # Use normal 'stopstart' mode instead! internal "SIGHUP won't fully unload internet config, try without '-k'" fi } usage() { { # '-k' option to remain undocumented until bugs fixed - see below echo "Usage: $PROGNAME [ -d | -v ] [ -p ]" echo " $PROGNAME -V" echo "Env: PPPLCD_WANNABE = { 0 | 1 }" } >&2 exit 1 } #shpp include utils.sh.shpp #shpp include gep.sh.shpp