rpms/ypbind/devel ypbind.init,1.23,1.24 ypbind.spec,1.67,1.68

Karel Klíč kklic at fedoraproject.org
Thu Jan 21 21:22:12 UTC 2010


Author: kklic

Update of /cvs/pkgs/rpms/ypbind/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv341

Modified Files:
	ypbind.init ypbind.spec 
Log Message:
Improved initscript


Index: ypbind.init
===================================================================
RCS file: /cvs/pkgs/rpms/ypbind/devel/ypbind.init,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -r1.23 -r1.24
--- ypbind.init	8 Apr 2009 10:53:09 -0000	1.23
+++ ypbind.init	21 Jan 2010 21:22:12 -0000	1.24
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
 #
-# ypbind:       Starts the ypbind Daemon
+# ypbind:       Starts the ypbind daemon
 #
 # Version:      @(#) /etc/init.d/ypbind.init 1.3
 #
@@ -11,13 +11,18 @@
 #              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.
-. /etc/init.d/functions
+[ -f /etc/rc.d/init.d/functions ] || exit 0
+. /etc/rc.d/init.d/functions
 
-. /etc/sysconfig/network
+# 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
@@ -29,161 +34,183 @@ OTHER_YPBIND_OPTS=""
 # Check that networking is configured.
 [ "${NETWORKING}" = "no" ] && exit 0
 
+exec="/sbin/ypbind"
+prog="ypbind"
+lockfile=/var/lock/subsys/$prog
+
 selinux_on() {
-        [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
-	#echo $"Turning on allow_ypbind SELinux boolean"
-        setsebool allow_ypbind=1
+    [ -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 || return
-	allow_ypbind=0
-	.  /etc/selinux/config
-	if [ -e /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local ]; then
-		. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
-	fi
-	if [ $allow_ypbind == 0 ]; then
-		#echo $"Turning off allow_ypbind SELinux boolean"
-		setsebool allow_ypbind=$allow_ypbind
-	fi
+    [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
+    allow_ypbind=0
+    .  /etc/selinux/config
+    if [ -e /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local ]; then
+	. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
+    fi
+    if [ $allow_ypbind == 0 ]; then
+	#echo $"Turning off allow_ypbind SELinux boolean"
+	setsebool allow_ypbind=$allow_ypbind
+    fi
 }
 
 start() {
-	DOMAINNAME=`domainname`
-	if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
-		echo -n $"Setting NIS domain: "
-		if [ -n "$NISDOMAIN" ]; then
-			action $"domain is '$NISDOMAIN' " domainname $NISDOMAIN
-		else # See if the domain is set in config file
-			NISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \
-				awk '{print $2}'`
-	   		if [ -n "$NISDOMAIN" ]; then
-				action $"domain is '$NISDOMAIN' " \
-					domainname $NISDOMAIN
-	   		else
-				action $"domain not found" /bin/false
-				logger -t ypbind $"domain not found"
-	        		return 1
-			fi
-		fi
-	fi
-	echo -n $"Starting NIS service: "
-	selinux_on
-	daemon ypbind $OTHER_YPBIND_OPTS
-	RETVAL=$?
-	echo
-	if [ $RETVAL -ne 0 ]; then
-	    #selinux_off
-	    logger -t ypbind "failed to start!"
-	    return $RETVAL
-	fi
-	echo -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.
-	timeout=10
-	firsttime=1
-        SECONDS=0
-	while [ $SECONDS -lt $timeout ]; do
-		if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind
-		then
-			if [ $firsttime -eq 1 ]; then
-				# reset timeout
-				timeout=$NISTIMEOUT
-				firsttime=0
-			fi
-			/usr/bin/ypwhich > /dev/null 2>&1
-		    	RETVAL=$?
-	    		if [ $RETVAL -eq 0 ]; then
-				break;
-	    		fi
-		fi
-		sleep 2
-		echo -n "."
-	done
-	if [ $RETVAL -eq 0 ]; then
-		logger -t ypbind \
-			"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
-		touch /var/lock/subsys/ypbind
-		success
-	else
-		logger -t ypbind \
-			"NIS server for domain `domainname` is not responding."
-		failure
-		#selinux_off
-		RETVAL=100
-	fi
-	echo
-	return $RETVAL
+    [ $UID -eq 0 ] || exit 4
+    [ -x $exec ] || exit 5
+    DOMAINNAME=`domainname`
+    if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
+	echo -n $"Setting NIS domain: "
+	if [ -n "$NISDOMAIN" ]; then
+	    action $"domain is '$NISDOMAIN' " domainname $NISDOMAIN
+	else # See if the domain is set in config file
+	    NISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \
+		awk '{print $2}'`
+	    if [ -n "$NISDOMAIN" ]; then
+		action $"domain is '$NISDOMAIN' " \
+		    domainname $NISDOMAIN
+	    else
+		action $"domain not found" /bin/false
+		logger -t ypbind $"domain not found"
+	        return 1
+	    fi
+	fi
+    fi
+    echo -n $"Starting NIS service: "
+    selinux_on
+    daemon $exec $OTHER_YPBIND_OPTS
+    retval=$?
+    echo
+    if [ $retval -ne 0 ]; then
+        #selinux_off
+	logger -t ypbind "failed to start!"
+	return $retval
+    fi
+    echo -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.
+    timeout=10
+    firsttime=1
+    SECONDS=0
+    while [ $SECONDS -lt $timeout ]; do
+	if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind
+	then
+	    if [ $firsttime -eq 1 ]; then
+		# reset timeout
+		timeout=$NISTIMEOUT
+		firsttime=0
+	    fi
+	    /usr/bin/ypwhich > /dev/null 2>&1
+	    retval=$?
+	    if [ $retval -eq 0 ]; then
+		break;
+	    fi
+	fi
+	sleep 2
+	echo -n "."
+    done
+    if [ $retval -eq 0 ]; then
+	logger -t ypbind \
+	    "NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
+	touch $lockfile
+	success
+    else
+	logger -t ypbind \
+	    "NIS server for domain `domainname` is not responding."
+	failure
+	#selinux_off
+	retval=100
+    fi
+    echo
+    return $retval
 }
 
 stop() {
-	echo -n $"Shutting down NIS service: "
-	killproc ypbind
-	RETVAL=$?
-	if [ $RETVAL -eq 0 ]; then
-		rm -f /var/lock/subsys/ypbind
-		# if  we used brute force (like kill -9) we don't want those around
-		if [ x$(domainname) != x ]; then
-			rm -f /var/yp/binding/$(domainname)*
-		fi
-	fi
-	echo
-	#selinux_off
-	return $RETVAL
+    [ $UID -eq 0 ] || exit 4
+    [ -x $exec ] || exit 5
+    echo -n $"Shutting down NIS service: "
+    killproc $prog
+    retval=$?
+    echo
+    if [ $retval -eq 0 ]; then
+	rm -f $lockfile
+	# if  we used brute force (like kill -9) we don't want those around
+	if [ x$(domainname) != x ]; then
+	    rm -f /var/yp/binding/$(domainname)*
+	fi
+    fi
+    #selinux_off
+    return $retval
 }
 
 restart() {
-	stop
-	start
+    stop
+    start
 }
 
 reload() {
-	echo -n $"Reloading NIS service: "
-        p=`/sbin/pidof -o %PPID 'ypbind'`
-        RETVAL=$?
-        if [ "$RETVAL" -eq 0 ]; then
-            /bin/kill -HUP $p
-            RETVAL=$?
-        fi
-        [ "$RETVAL" -eq 0 ] && success || failure
-        echo
-        return $RETVAL
+    echo -n $"Reloading NIS service: "
+    killproc $prog -HUP
+    retval=$?
+    echo
+    return $retval
 }
 
-RETVAL=0
+force_reload() {
+    restart
+}
+
+rh_status() {
+    # run checks to determine if the service is running or use generic status
+    status $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" in
-  start)
-	start
-	RETVAL=$?
-	if [ $RETVAL -eq 100 ]; then stop; RETVAL=1; fi
-	;;
-  stop)
-	stop
-	RETVAL=$?
-	;;
-  status)
-	status ypbind
-	RETVAL=$?
+    start)
+	rh_status_q && exit 0
+	$1
+	retval=$?
+	if [ $retval -eq 100 ]; then stop; exit 1; fi
+	exit $retval
+	;;
+    stop)
+        rh_status_q || exit 0
+	$1	
+	;;
+    restart)
+	$1
+	;;
+    reload)
+	rh_status_q || exit 7
+	$1
 	;;
-  restart)
-	restart
-	RETVAL=$?
+    force-reload)
+	force_reload
 	;;
-  condrestart|try-restart)
-	if [ -e /var/lock/subsys/ypbind ]; then restart; fi
+    status)
+	rh_status
 	;;
-  reload)
-	reload
+    condrestart|try-restart)
+	rh_status_q || exit 0
+	restart
 	;;
-  force-reload)
-	if ! reload; then restart; fi
+    usage)
+	$1
 	;;
-  *)
-	echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status}"
-	RETVAL=3
+    *)
+	usage
+	exit 2
 esac
-
-exit $RETVAL
+exit $?


Index: ypbind.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ypbind/devel/ypbind.spec,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -p -r1.67 -r1.68
--- ypbind.spec	4 Jan 2010 16:36:02 -0000	1.67
+++ ypbind.spec	21 Jan 2010 21:22:12 -0000	1.68
@@ -1,7 +1,7 @@
 Summary: The NIS daemon which binds NIS clients to an NIS domain
 Name: ypbind
 Version: 1.31
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2
 Group: System Environment/Daemons
 Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
@@ -85,6 +85,10 @@ fi
 %doc README NEWS
 
 %changelog
+* Thu Jan 21 2010 Karel Klic <kklic at redhat.com> - 3:1.31-2
+- Rewrote initscript to become closer to Packaging:SysVInitScript
+  Fedora guildeline. Also fixes rhbz#523913
+
 * Mon Jan  4 2010 Karel Klic <kklic at redhat.com> - 3:1.31-1
 - Updated to version 1.31 from upstream
 - Removed signalstate patch because it was merged by upstream



More information about the scm-commits mailing list