1*7c478bd9Sstevel@tonic-gate#!/bin/sh 2*7c478bd9Sstevel@tonic-gate# 3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START 4*7c478bd9Sstevel@tonic-gate# 5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*7c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*7c478bd9Sstevel@tonic-gate# with the License. 9*7c478bd9Sstevel@tonic-gate# 10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 13*7c478bd9Sstevel@tonic-gate# and limitations under the License. 14*7c478bd9Sstevel@tonic-gate# 15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*7c478bd9Sstevel@tonic-gate# 21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END 22*7c478bd9Sstevel@tonic-gate# 23*7c478bd9Sstevel@tonic-gate# 24*7c478bd9Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 25*7c478bd9Sstevel@tonic-gate# Use is subject to license terms. 26*7c478bd9Sstevel@tonic-gate# 27*7c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate# 29*7c478bd9Sstevel@tonic-gate# Enable appropriate NIS daemons based on the current configuration. 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gateenable () { 32*7c478bd9Sstevel@tonic-gate /usr/sbin/svcadm enable -t $1 33*7c478bd9Sstevel@tonic-gate [ $? = 0 ] || echo "ypstart: unable to enable $1" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate if [ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ]; then 36*7c478bd9Sstevel@tonic-gate echo "ypstart: unable to enable $1; in maintenance" 37*7c478bd9Sstevel@tonic-gate fi 38*7c478bd9Sstevel@tonic-gate} 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gatedomain=`domainname` 42*7c478bd9Sstevel@tonic-gateif [ -z "$domain" ]; then 43*7c478bd9Sstevel@tonic-gate echo "ERROR: Default domain is not defined. \c" 44*7c478bd9Sstevel@tonic-gate echo "Use \"domainname\" to set the domain." 45*7c478bd9Sstevel@tonic-gate exit 1 46*7c478bd9Sstevel@tonic-gatefi 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gateecho "starting NIS (YP server) services:\c" 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gatezone=`/usr/bin/zonename` 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gateif [ -d /var/yp/$domain ]; then 53*7c478bd9Sstevel@tonic-gate state=`/usr/bin/svcprop -p restarter/state network/nis/server:default` 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypserv`" ]; then 56*7c478bd9Sstevel@tonic-gate echo "ypstart: ypserv already running?" 57*7c478bd9Sstevel@tonic-gate fi 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate enable svc:/network/nis/server:default && echo " ypserv\c" 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate YP_SERVER=TRUE # remember we're a server for later 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate # check to see if we are the master 64*7c478bd9Sstevel@tonic-gate if [ -f /var/yp/NISLDAPmapping ]; then 65*7c478bd9Sstevel@tonic-gate passwdfile=/var/yp/$domain/LDAP_passwd.byname 66*7c478bd9Sstevel@tonic-gate else 67*7c478bd9Sstevel@tonic-gate passwdfile=/var/yp/$domain/passwd.byname 68*7c478bd9Sstevel@tonic-gate fi 69*7c478bd9Sstevel@tonic-gate master=`/usr/sbin/makedbm -u $passwdfile | grep YP_MASTER_NAME \ 70*7c478bd9Sstevel@tonic-gate | nawk '{ print tolower($2) }'` 71*7c478bd9Sstevel@tonic-gatefi 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate# Enabling the YP client is not strictly necessary, but it is 74*7c478bd9Sstevel@tonic-gate# traditional. 75*7c478bd9Sstevel@tonic-gatestate=`/usr/bin/svcprop -p restarter/state network/nis/client:default` 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate[ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypbind`" ]; then 78*7c478bd9Sstevel@tonic-gate echo "ypstart: ypbind already running?" 79*7c478bd9Sstevel@tonic-gatefi 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gateenable svc:/network/nis/client:default && echo " ypbind\c" 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate# do a ypwhich to force ypbind to get bound 84*7c478bd9Sstevel@tonic-gateypwhich > /dev/null 2>&1 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gateif [ "$YP_SERVER" = TRUE ]; then 87*7c478bd9Sstevel@tonic-gate # Are we the master server? If so, start the 88*7c478bd9Sstevel@tonic-gate # ypxfrd, rpc.yppasswdd and rpc.ypupdated daemons. 89*7c478bd9Sstevel@tonic-gate hostname=`uname -n | tr '[A-Z]' '[a-z]'` 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate if [ "$master" = "$hostname" ]; then 92*7c478bd9Sstevel@tonic-gate enable svc:/network/nis/xfr:default && echo " ypxfrd\c" 93*7c478bd9Sstevel@tonic-gate enable svc:/network/nis/passwd:default && 94*7c478bd9Sstevel@tonic-gate echo " rpc.yppasswdd\c" 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate if [ ! -f /var/yp/NISLDAPmapping -a -f /var/yp/updaters ]; then 97*7c478bd9Sstevel@tonic-gate enable svc:/network/nis/update:default && 98*7c478bd9Sstevel@tonic-gate echo " rpc.ypupdated\c" 99*7c478bd9Sstevel@tonic-gate fi 100*7c478bd9Sstevel@tonic-gate fi 101*7c478bd9Sstevel@tonic-gatefi 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate# As this operation is likely configuration changing, restart the 104*7c478bd9Sstevel@tonic-gate# name-services milestone (such that configuration-sensitive services 105*7c478bd9Sstevel@tonic-gate# are in turn restarted). 106*7c478bd9Sstevel@tonic-gate/usr/sbin/svcadm restart milestone/name-services 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gateecho " done." 109