home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / usr / lib / hpnp / cfg / getsyslog / getsyslog~
Text File  |  1998-08-19  |  3KB  |  119 lines

  1. #!/bin/ksh
  2. #ident    "@(#)getsyslog    1.2"
  3. #        copyright    "%c%"
  4. #
  5. # (c)Copyright Hewlett-Packard Company 1991.  All Rights Reserved.
  6. # (c)Copyright 1983 Regents of the University of California
  7. # (c)Copyright 1988, 1989 by Carnegie Mellon University
  8. #                          RESTRICTED RIGHTS LEGEND
  9. # Use, duplication, or disclosure by the U.S. Government is subject to
  10. # restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
  11. # Technical Data and Computer Software clause in DFARS 252.227-7013.
  12. #
  13. #                          Hewlett-Packard Company
  14. #                          3000 Hanover Street
  15. #                          Palo Alto, CA 94304 U.S.A.
  16. #
  17.  
  18. while [ 0 ] 
  19. do
  20.   echo "\nEnter syslog server name or address (optional): $NL"  
  21.   read -r SYSLOGIP
  22.   if [ -z "$SYSLOGIP" ]
  23.   then
  24.     break
  25.   fi
  26.   if [ "$SYSLOGIP" = "q" ]
  27.   then    
  28.     exit 1
  29.   fi
  30.   if [ "$SYSLOGIP" = "?" ]
  31.   then
  32.     echo "\nThe network peripheral will send syslog messages to a syslog "
  33.     echo "server.  Syslog messages, for example, identify when the peripheral"
  34.     echo "powers up or when there is a paper problem.  If no syslog server is"
  35.     echo "entered, the network peripheral will not send out syslog messages."
  36.     echo "An example of a valid syslog server address is 15.43.4.7\n"
  37.     $QUITHELP
  38.     continue
  39.   fi
  40.   LOOKUPSYSLOGIP="`gethostaddr $SYSLOGIP`"
  41.   WASADDR=$?
  42.   if [ $WASADDR -eq 1 ]
  43.   then
  44.     echo $LOOKUPSYSLOGIP | egrep '^[0-9]+\.[0-9]+.[0-9]+.[0-9]+$' >/dev/null
  45.     if [ $? -eq 1 ]
  46.     then
  47.       echo ""
  48.       echo "$SYSLOGIP is not a valid address."
  49.       continue
  50.     fi
  51.   fi
  52.   if [ -z "$LOOKUPSYSLOGIP" ]
  53.   then
  54.     echo ""
  55.     echo "$SYSLOGIP: unknown host"
  56.   else
  57.     onlyoneaddr $SYSLOGIP $LOOKUPSYSLOGIP
  58.     RETCODE=$?
  59.     SYSLOGIP=`cat $TMP/ONEADDR`
  60.     rm -f $TMP/ONEADDR
  61.     if [ $RETCODE -eq 1 ]
  62.     then
  63.       exit 1
  64.     fi
  65.     if [ -n "$SYSLOGIP" ]
  66.     then
  67.       break
  68.     fi
  69.   fi
  70. done
  71.  
  72. echo $SYSLOGIP    > "$TMP/SYSLOGIP"
  73. if [ -z "$SYSLOGIP" ]
  74. then
  75.   exit 0
  76. fi
  77.  
  78. while [ 0 ] 
  79. do
  80.   echo "\nEnter syslog facility (lpr/local0/.../local7 default=lpr): $NL"  
  81.   read -r SYSLOGFAC
  82.   if [ -z "$SYSLOGFAC" ]
  83.   then
  84.     break
  85.   fi
  86.   if [ "$SYSLOGFAC" = "q" ]
  87.   then    
  88.     exit 1
  89.   fi
  90.   if [ "$SYSLOGFAC" = "?" ]
  91.   then
  92.     echo "\nThe network peripheral will send syslog messages to a syslog "
  93.     echo "server.  The syslog facility describes the part of the system that"
  94.     echo "generated the message.  The network peripheral interface can be"
  95.     echo "configured to generate syslog messages with the facility local0"
  96.     echo "through local7.  The default facility is lpr.\n"
  97.     $QUITHELP
  98.     continue
  99.   fi
  100.   case "$SYSLOGFAC" in
  101.     local[0-7]) break ;;
  102.     lpr) SYSLOGFAC=""
  103.      break ;;
  104.     *) echo ""
  105.        echo "Invalid syslog facility."
  106.        echo ""
  107.        echo "Valid choices are: local0, local1, local2, local3, local4, local5"
  108.        echo "                   local6, local7"
  109.        echo ""
  110.        $QUITHELP
  111.        ;;
  112.   esac
  113. done
  114.  
  115. echo $SYSLOGFAC > "$TMP/SYSLOGFAC"
  116.  
  117. exit 0
  118.