Print this page
XXX Remove nawk(1)


   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # ident "%Z%%M% %I%     %E% SMI"
  27 #
  28 # Enable appropriate NIS daemons based on the current configuration.
  29 
  30 enable () {
  31         /usr/sbin/svcadm enable -t $1
  32         [ $? = 0 ] || echo "ypstart: unable to enable $1"
  33 
  34         if [ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ]; then
  35                 echo "ypstart: unable to enable $1; in maintenance"
  36         fi
  37 }
  38 
  39 
  40 domain=`domainname`
  41 if [ -z "$domain" ]; then
  42         echo "ERROR: Default domain is not defined.  \c"
  43         echo "Use \"domainname\" to set the domain."
  44         exit 1
  45 fi
  46 
  47 echo "starting NIS (YP server) services:\c"


  49 zone=`/sbin/zonename`
  50 
  51 if [ -d /var/yp/$domain ]; then
  52         state=`/usr/bin/svcprop -p restarter/state network/nis/server:default`
  53 
  54         [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypserv`" ]; then
  55                 echo "ypstart: ypserv already running?"
  56         fi
  57 
  58         enable svc:/network/nis/server:default && echo " ypserv\c"
  59 
  60         YP_SERVER=TRUE  # remember we're a server for later
  61 
  62         # check to see if we are the master
  63         if [ -f /var/yp/NISLDAPmapping ]; then
  64                 passwdfile=/var/yp/$domain/LDAP_passwd.byname
  65         else
  66                 passwdfile=/var/yp/$domain/passwd.byname
  67         fi
  68         master=`/usr/sbin/makedbm -u $passwdfile | grep YP_MASTER_NAME \
  69             | nawk '{ print tolower($2) }'`
  70 fi
  71 
  72 # Enabling the YP client is not strictly necessary, but it is
  73 # traditional.
  74 state=`/usr/bin/svcprop -p restarter/state network/nis/client:default`
  75 
  76 [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypbind`" ]; then
  77         echo "ypstart: ypbind already running?"
  78 fi
  79 
  80 enable svc:/network/nis/client:default && echo " ypbind\c"
  81 
  82 # do a ypwhich to force ypbind to get bound
  83 ypwhich > /dev/null 2>&1
  84 
  85 if [ "$YP_SERVER" = TRUE ]; then
  86         # Are we the master server?  If so, start the
  87         # ypxfrd, rpc.yppasswdd and rpc.ypupdated daemons.
  88         hostname=`uname -n | tr '[A-Z]' '[a-z]'`
  89 


   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #


  26 # Enable appropriate NIS daemons based on the current configuration.
  27 
  28 enable () {
  29         /usr/sbin/svcadm enable -t $1
  30         [ $? = 0 ] || echo "ypstart: unable to enable $1"
  31 
  32         if [ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ]; then
  33                 echo "ypstart: unable to enable $1; in maintenance"
  34         fi
  35 }
  36 
  37 
  38 domain=`domainname`
  39 if [ -z "$domain" ]; then
  40         echo "ERROR: Default domain is not defined.  \c"
  41         echo "Use \"domainname\" to set the domain."
  42         exit 1
  43 fi
  44 
  45 echo "starting NIS (YP server) services:\c"


  47 zone=`/sbin/zonename`
  48 
  49 if [ -d /var/yp/$domain ]; then
  50         state=`/usr/bin/svcprop -p restarter/state network/nis/server:default`
  51 
  52         [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypserv`" ]; then
  53                 echo "ypstart: ypserv already running?"
  54         fi
  55 
  56         enable svc:/network/nis/server:default && echo " ypserv\c"
  57 
  58         YP_SERVER=TRUE  # remember we're a server for later
  59 
  60         # check to see if we are the master
  61         if [ -f /var/yp/NISLDAPmapping ]; then
  62                 passwdfile=/var/yp/$domain/LDAP_passwd.byname
  63         else
  64                 passwdfile=/var/yp/$domain/passwd.byname
  65         fi
  66         master=`/usr/sbin/makedbm -u $passwdfile | grep YP_MASTER_NAME \
  67             | /usr/xpg4/bin/awk '{ print tolower($2) }'`
  68 fi
  69 
  70 # Enabling the YP client is not strictly necessary, but it is
  71 # traditional.
  72 state=`/usr/bin/svcprop -p restarter/state network/nis/client:default`
  73 
  74 [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypbind`" ]; then
  75         echo "ypstart: ypbind already running?"
  76 fi
  77 
  78 enable svc:/network/nis/client:default && echo " ypbind\c"
  79 
  80 # do a ypwhich to force ypbind to get bound
  81 ypwhich > /dev/null 2>&1
  82 
  83 if [ "$YP_SERVER" = TRUE ]; then
  84         # Are we the master server?  If so, start the
  85         # ypxfrd, rpc.yppasswdd and rpc.ypupdated daemons.
  86         hostname=`uname -n | tr '[A-Z]' '[a-z]'`
  87