xref: /illumos-gate/usr/src/cmd/rpcbind/rpc-bind.sh (revision 3fd3a04a)
17c478bd9Sstevel@tonic-gate#! /sbin/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
67c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
77c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
87c478bd9Sstevel@tonic-gate# with the License.
97c478bd9Sstevel@tonic-gate#
107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
137c478bd9Sstevel@tonic-gate# and limitations under the License.
147c478bd9Sstevel@tonic-gate#
157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# CDDL HEADER END
227c478bd9Sstevel@tonic-gate#
237c478bd9Sstevel@tonic-gate#
24*3fd3a04aSthurlow# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate# Use is subject to license terms.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate# rpcbind method
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gate# Argument is the method name.
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gateRB_OPT="$1"
377c478bd9Sstevel@tonic-gateRB_EXIT=0
387c478bd9Sstevel@tonic-gateRB_DOOR="/var/run/rpc_door"
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gatecase ${RB_OPT} in
417c478bd9Sstevel@tonic-gate	"start")
427c478bd9Sstevel@tonic-gate		if [ ! -x /usr/sbin/rpcbind ]
437c478bd9Sstevel@tonic-gate		then
447c478bd9Sstevel@tonic-gate			echo "ERROR: /usr/sbin/rpcbind does not exist."
45*3fd3a04aSthurlow			exit $SMF_EXIT_ERR_CONFIG
467c478bd9Sstevel@tonic-gate		fi
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate		[ -d ${RB_DOOR} ] || /usr/bin/mkdir -p -m 1777 ${RB_DOOR}
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate		/usr/sbin/rpcbind > /dev/msglog 2>&1
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate		RB_EXIT=${?}
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate		if [ $RB_EXIT != 0 ]
557c478bd9Sstevel@tonic-gate		then
567c478bd9Sstevel@tonic-gate			echo "rpcbind failed with $RB_EXIT."
577c478bd9Sstevel@tonic-gate			RB_EXIT=1
587c478bd9Sstevel@tonic-gate		fi
597c478bd9Sstevel@tonic-gate	;;
607c478bd9Sstevel@tonic-gate	"stop")
617c478bd9Sstevel@tonic-gate		# Kill service contract
627c478bd9Sstevel@tonic-gate		smf_kill_contract $2 TERM 1
637c478bd9Sstevel@tonic-gate		[ $? -ne 0 ] && RB_EXIT=1
647c478bd9Sstevel@tonic-gate		/usr/bin/rm -fr ${RB_DOOR}
657c478bd9Sstevel@tonic-gate	;;
667c478bd9Sstevel@tonic-gate	*)
677c478bd9Sstevel@tonic-gate		RB_EXIT=$SMF_EXIT_ERR_CONFIG
687c478bd9Sstevel@tonic-gate	;;
697c478bd9Sstevel@tonic-gateesac
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gateexit ${RB_EXIT}
72