Rev 4 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/sh## ypbind: Starts the ypbind daemon## Version: @(#) /etc/init.d/ypbind.init 1.3## chkconfig: - 24 76# description: This is a daemon which runs on NIS/YP clients and binds them \# to a NIS domain. It must be running for systems based on glibc \# to work as NIS clients, but it should not be enabled on systems \# which are not using NIS.# processname: ypbind# config: /etc/yp.conf## See https://fedoraproject.org/wiki/Packaging:SysVInitScript for# the guidelines document.OTHER_YPBIND_OPTS=""# Source function library.[ -f /etc/rc.d/init.d/functions ] || exit 0. /etc/rc.d/init.d/functions# getting the YP domain name[ -e /etc/sysconfig/network ] && . /etc/sysconfig/network# Check for and source configuration file otherwise set defaults[ -f /etc/sysconfig/ypbind ] && . /etc/sysconfig/ypbind# NISTIMEOUT should be a multiple of 15 since# ypwhich has a hardcoded 15sec timeout[ -z "$NISTIMEOUT" ] && NISTIMEOUT=45# Check that networking is configured.[ "${NETWORKING}" = "no" ] && exit 0exec="/usr/sbin/ypbind"prog="ypbind"lockfile=/var/lock/subsys/$progselinux_on() {[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return#echo $"Turning on allow_ypbind SELinux boolean"setsebool allow_ypbind=1}selinux_off() {[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || returnallow_ypbind=0. /etc/selinux/configif [ -e /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local ]; then. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.localfiif [ $allow_ypbind == 0 ]; then#echo $"Turning off allow_ypbind SELinux boolean"setsebool allow_ypbind=$allow_ypbindfi}start() {[ $UID -eq 0 ] || exit 4[ -x $exec ] || exit 5DOMAINNAME=`domainname`if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; thenecho -n $"Setting NIS domain: "if [ -n "$NISDOMAIN" ]; thenaction $"domain is '$NISDOMAIN' " domainname $NISDOMAINelse # See if the domain is set in config fileNISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \awk '{print $2}' | head -1`if [ -n "$NISDOMAIN" ]; thenaction $"domain is '$NISDOMAIN' " \domainname $NISDOMAINelseaction $"domain not found" /bin/falselogger -t ypbind $"domain not found"return 1fififi#/etc/rpc checkgrep ypbind /etc/rpc > /dev/null 2>&1if [ $? -ne 0 ]; thenaction $"Error: Missing ypbind entry in /etc/rpc." falseexit 1fiecho -n $"Starting NIS service: "selinux_ondaemon $exec $OTHER_YPBIND_OPTSretval=$?echoif [ $retval -ne 0 ]; then#selinux_offlogger -t ypbind "failed to start!"return $retvalfiretval=-1echo -n $"Binding NIS service: "# the following fixes problems with the init scripts continuing# even when we are really not bound yet to a server, and then things# that need NIS fail.firsttime=1SECONDS=0while [ $SECONDS -lt $NISTIMEOUT ] || [ $firsttime -eq 1 ] ; dofirsttime=0if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbindthen/usr/bin/ypwhich > /dev/null 2>&1retval=$?if [ $retval -eq 0 ]; thenbreak;fifisleep 2echo -n "."doneif [ $retval -eq 0 ]; thenlogger -t ypbind \"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"touch $lockfilesuccesselif [ $retval -eq -1 ]; thenlogger -t ypbind \"NIS service failed to register to rpcbind."failure#selinux_offretval=90elselogger -t ypbind \"NIS server for domain `domainname` is not responding."failure#selinux_offretval=100fiechoreturn $retval}stop() {[ $UID -eq 0 ] || exit 4[ -x $exec ] || exit 5echo -n $"Shutting down NIS service: "killproc $progretval=$?echoif [ $retval -eq 0 ]; thenrm -f $lockfile# if we used brute force (like kill -9) we don't want those aroundif [ x$(domainname) != x ]; thenrm -f /var/yp/binding/$(domainname)*fifi#selinux_offreturn $retval}restart() {stopstart}reload() {echo -n $"Reloading NIS service: "killproc $prog -HUPretval=$?echoreturn $retval}force_reload() {restart}rh_status() {# run checks to determine if the service is running or use generic statusstatus $prog}rh_status_q() {rh_status >/dev/null 2>&1}usage() {echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"}# See how we were called.case "$1" instart)rh_status_q && exit 0$1retval=$?if [ $retval -eq 100 ]; then stop; exit 1; fiexit $retval;;stop)rh_status_q || exit 0$1;;restart)$1;;reload)rh_status_q || exit 7$1;;force-reload)force_reload;;status)rh_status;;condrestart|try-restart)rh_status_q || exit 0restart;;usage)$1;;*)usageexit 2esacexit $?