#!/bin/sh
#
# Copyright 1996 Sun Microsystems, Inc. All Rights Reserved
#
# @(#)nameserv.sh	3.2 99/03/12 Sun Microsystems, Inc.
#
# Install script for bootstrapping SunScreen EFS after a
# fresh installation of SKIP and SunScreen EFS.
#
# For this script to work the following must be completed:
#    1. SKIP packages are installed
#    2. SunScreen EFS packages are installed
#    3. the machine was rebooted (to start SKIP)
#
# Exit Codes:
#    0       success
#    2       missing packages
#    3       bad argument
#    4       invalid security level selected
#    5       error occured during compilation
#    6       error occured activating the configuration
#

PATH="/opt/SUNWicg/bin:/opt/SUNWicg/SunScreen/bin:/usr/bin"
export PATH

#
# Defaults
#
CONFIG_NAME="Initial"
CERT_TYPE="UDH"
LOCAL_ONLY=""
ROUTING=""
CERT_DISC=""
NAME_SERVICE_TYPE=""
SECURITY_LEVEL=""

set_name_service(){
  #
  # figure out the name service type from /etc/nsswitch.conf
  #
  if [ -r /etc/nsswitch.conf ] ; then
    SERVICES=`grep "^hosts:" /etc/nsswitch.conf | awk '{ print $2,$3,$4,$5 }'`
    NAME_SERVICE_TYPE=""
    for NS in $SERVICES ; do
      if [ "$NAME_SERVICE_TYPE" != "NIS_DNS" ] ; then
        case $NS in
          DNS|dns)

                   if [ "$NAME_SERVICE_TYPE" = "NIS" ] ; then
                     NAME_SERVICE_TYPE="NIS_DNS"
                   else
                     NAME_SERVICE_TYPE="DNS"
                   fi
                   ;;
          NIS|nis)
                   if [ "$NAME_SERVICE_TYPE" = "DNS" ] ; then
                     NAME_SERVICE_TYPE="NIS_DNS"
                   else
                     NAME_SERVICE_TYPE="NIS"
                     fi
                   ;;
          *)
                   # skip bogus nsswitch entries
                   ;;
        esac
      fi     
    done
   fi    
}
### Getting name service used by system
set_name_service
echo "$NAME_SERVICE_TYPE" 
