- Changed init script to look in /etc/yp.conf for the domain name when not
already set. (bz 113386) - Reworked init script to eliminate unreasonable hangs when ypbind cannot bind to nis server. (bz 112770)
This commit is contained in:
parent
2fb6b54bab
commit
713c992128
79
ypbind.init
79
ypbind.init
@ -22,14 +22,16 @@ OTHER_YPBIND_OPTS=""
|
||||
# Check for and source configuration file otherwise set defaults
|
||||
[ -f /etc/sysconfig/ypbind ] && . /etc/sysconfig/ypbind
|
||||
|
||||
[ -z "$NISTIMEOUT" ] && NISTIMEOUT=20
|
||||
# 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 0
|
||||
|
||||
selinux_on() {
|
||||
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
|
||||
echo $"Turning on allow_ypbind SELinux boolean"
|
||||
#echo $"Turning on allow_ypbind SELinux boolean"
|
||||
setsebool allow_ypbind=1
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ selinux_off() {
|
||||
. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
|
||||
fi
|
||||
if [ $allow_ypbind == 0 ]; then
|
||||
echo $"Turning off allow_ypbind SELinux boolean"
|
||||
#echo $"Turning off allow_ypbind SELinux boolean"
|
||||
setsebool allow_ypbind=$allow_ypbind
|
||||
fi
|
||||
}
|
||||
@ -49,63 +51,79 @@ selinux_off() {
|
||||
start() {
|
||||
DOMAINNAME=`domainname`
|
||||
if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
|
||||
if [ -n "$NISDOMAIN" ]; then
|
||||
action $"Setting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
selinux_on
|
||||
echo -n $"Binding to the NIS domain: "
|
||||
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.
|
||||
echo -n $"Listening for an NIS domain server."
|
||||
for (( times = 1; times < $NISTIMEOUT; times++ )); do
|
||||
/usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind && ypwhich > /dev/null 2>&1
|
||||
timeout=$NISTIMEOUT
|
||||
while [ $timeout -gt 0 ]; do
|
||||
/usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind && \
|
||||
/usr/bin/ypwhich > /dev/null 2>&1
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
break;
|
||||
fi
|
||||
sleep 1
|
||||
echo -n "."
|
||||
echo -n "..."
|
||||
# ypwhich has a hardcode 15sec timeout
|
||||
# so subtract that from NISTIMEOUT to
|
||||
# to see of we should continue to wait
|
||||
timeout=`expr $timeout - 15`
|
||||
done
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
logger -t ypbind "bound to NIS server `ypwhich 2> /dev/null`"
|
||||
logger -t ypbind \
|
||||
"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
|
||||
touch /var/lock/subsys/ypbind
|
||||
success
|
||||
else
|
||||
killproc 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
|
||||
failure "attempting to contact yp server"
|
||||
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 services: "
|
||||
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
|
||||
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
|
||||
selinux_off
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
@ -119,7 +137,8 @@ RETVAL=0
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
start
|
||||
[ $? -eq 100 ] && stop
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
|
@ -92,6 +92,10 @@ exit 0
|
||||
%changelog
|
||||
* Tue Apr 17 2007 Steve Dickson <steved@redhat.com> - 3:1.19-9
|
||||
- Fixed typo in init script (bz 233459)
|
||||
- Changed init script to look in /etc/yp.conf for the
|
||||
domain name when not already set. (bz 113386)
|
||||
- Reworked init script to eliminate unreasonable
|
||||
hangs when ypbind cannot bind to nis server. (bz 112770)
|
||||
|
||||
* Tue Apr 3 2007 Steve Dickson <steved@redhat.com> - 3:1.19-8
|
||||
- Replace portmap dependency with an rpcbind dependency (bz 228894)
|
||||
|
Loading…
Reference in New Issue
Block a user