17c478bd9Sstevel@tonic-gate#!/bin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*6927f468Sdp# Common Development and Distribution License (the "License"). 7*6927f468Sdp# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 23*6927f468Sdp# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# 287c478bd9Sstevel@tonic-gate# Enable appropriate NIS daemons based on the current configuration. 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gateenable () { 317c478bd9Sstevel@tonic-gate /usr/sbin/svcadm enable -t $1 327c478bd9Sstevel@tonic-gate [ $? = 0 ] || echo "ypstart: unable to enable $1" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate if [ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ]; then 357c478bd9Sstevel@tonic-gate echo "ypstart: unable to enable $1; in maintenance" 367c478bd9Sstevel@tonic-gate fi 377c478bd9Sstevel@tonic-gate} 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gatedomain=`domainname` 417c478bd9Sstevel@tonic-gateif [ -z "$domain" ]; then 427c478bd9Sstevel@tonic-gate echo "ERROR: Default domain is not defined. \c" 437c478bd9Sstevel@tonic-gate echo "Use \"domainname\" to set the domain." 447c478bd9Sstevel@tonic-gate exit 1 457c478bd9Sstevel@tonic-gatefi 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gateecho "starting NIS (YP server) services:\c" 487c478bd9Sstevel@tonic-gate 49*6927f468Sdpzone=`/sbin/zonename` 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gateif [ -d /var/yp/$domain ]; then 527c478bd9Sstevel@tonic-gate state=`/usr/bin/svcprop -p restarter/state network/nis/server:default` 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate [ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypserv`" ]; then 557c478bd9Sstevel@tonic-gate echo "ypstart: ypserv already running?" 567c478bd9Sstevel@tonic-gate fi 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate enable svc:/network/nis/server:default && echo " ypserv\c" 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate YP_SERVER=TRUE # remember we're a server for later 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate # check to see if we are the master 637c478bd9Sstevel@tonic-gate if [ -f /var/yp/NISLDAPmapping ]; then 647c478bd9Sstevel@tonic-gate passwdfile=/var/yp/$domain/LDAP_passwd.byname 657c478bd9Sstevel@tonic-gate else 667c478bd9Sstevel@tonic-gate passwdfile=/var/yp/$domain/passwd.byname 677c478bd9Sstevel@tonic-gate fi 687c478bd9Sstevel@tonic-gate master=`/usr/sbin/makedbm -u $passwdfile | grep YP_MASTER_NAME \ 697c478bd9Sstevel@tonic-gate | nawk '{ print tolower($2) }'` 707c478bd9Sstevel@tonic-gatefi 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate# Enabling the YP client is not strictly necessary, but it is 737c478bd9Sstevel@tonic-gate# traditional. 747c478bd9Sstevel@tonic-gatestate=`/usr/bin/svcprop -p restarter/state network/nis/client:default` 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate[ "$state" = "disabled" ] && if [ -n "`pgrep -z $zone ypbind`" ]; then 777c478bd9Sstevel@tonic-gate echo "ypstart: ypbind already running?" 787c478bd9Sstevel@tonic-gatefi 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gateenable svc:/network/nis/client:default && echo " ypbind\c" 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate# do a ypwhich to force ypbind to get bound 837c478bd9Sstevel@tonic-gateypwhich > /dev/null 2>&1 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gateif [ "$YP_SERVER" = TRUE ]; then 867c478bd9Sstevel@tonic-gate # Are we the master server? If so, start the 877c478bd9Sstevel@tonic-gate # ypxfrd, rpc.yppasswdd and rpc.ypupdated daemons. 887c478bd9Sstevel@tonic-gate hostname=`uname -n | tr '[A-Z]' '[a-z]'` 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate if [ "$master" = "$hostname" ]; then 917c478bd9Sstevel@tonic-gate enable svc:/network/nis/xfr:default && echo " ypxfrd\c" 927c478bd9Sstevel@tonic-gate enable svc:/network/nis/passwd:default && 937c478bd9Sstevel@tonic-gate echo " rpc.yppasswdd\c" 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate if [ ! -f /var/yp/NISLDAPmapping -a -f /var/yp/updaters ]; then 967c478bd9Sstevel@tonic-gate enable svc:/network/nis/update:default && 977c478bd9Sstevel@tonic-gate echo " rpc.ypupdated\c" 987c478bd9Sstevel@tonic-gate fi 997c478bd9Sstevel@tonic-gate fi 1007c478bd9Sstevel@tonic-gatefi 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate# As this operation is likely configuration changing, restart the 1037c478bd9Sstevel@tonic-gate# name-services milestone (such that configuration-sensitive services 1047c478bd9Sstevel@tonic-gate# are in turn restarted). 1057c478bd9Sstevel@tonic-gate/usr/sbin/svcadm restart milestone/name-services 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gateecho " done." 108