Improved initscript
This commit is contained in:
parent
acd718da7e
commit
4ca34e74e6
289
ypbind.init
289
ypbind.init
@ -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
|
# Version: @(#) /etc/init.d/ypbind.init 1.3
|
||||||
#
|
#
|
||||||
@ -11,13 +11,18 @@
|
|||||||
# which are not using NIS.
|
# which are not using NIS.
|
||||||
# processname: ypbind
|
# processname: ypbind
|
||||||
# config: /etc/yp.conf
|
# config: /etc/yp.conf
|
||||||
|
#
|
||||||
|
# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
|
||||||
|
# the guidelines document.
|
||||||
|
|
||||||
OTHER_YPBIND_OPTS=""
|
OTHER_YPBIND_OPTS=""
|
||||||
|
|
||||||
# Source function library.
|
# 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
|
# Check for and source configuration file otherwise set defaults
|
||||||
[ -f /etc/sysconfig/ypbind ] && . /etc/sysconfig/ypbind
|
[ -f /etc/sysconfig/ypbind ] && . /etc/sysconfig/ypbind
|
||||||
@ -29,161 +34,183 @@ OTHER_YPBIND_OPTS=""
|
|||||||
# Check that networking is configured.
|
# Check that networking is configured.
|
||||||
[ "${NETWORKING}" = "no" ] && exit 0
|
[ "${NETWORKING}" = "no" ] && exit 0
|
||||||
|
|
||||||
|
exec="/sbin/ypbind"
|
||||||
|
prog="ypbind"
|
||||||
|
lockfile=/var/lock/subsys/$prog
|
||||||
|
|
||||||
selinux_on() {
|
selinux_on() {
|
||||||
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
|
[ -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
|
setsebool allow_ypbind=1
|
||||||
}
|
}
|
||||||
|
|
||||||
selinux_off() {
|
selinux_off() {
|
||||||
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
|
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
|
||||||
allow_ypbind=0
|
allow_ypbind=0
|
||||||
. /etc/selinux/config
|
. /etc/selinux/config
|
||||||
if [ -e /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local ]; then
|
if [ -e /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local ]; then
|
||||||
. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
|
. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
|
||||||
fi
|
fi
|
||||||
if [ $allow_ypbind == 0 ]; then
|
if [ $allow_ypbind == 0 ]; then
|
||||||
#echo $"Turning off allow_ypbind SELinux boolean"
|
#echo $"Turning off allow_ypbind SELinux boolean"
|
||||||
setsebool allow_ypbind=$allow_ypbind
|
setsebool allow_ypbind=$allow_ypbind
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
DOMAINNAME=`domainname`
|
[ $UID -eq 0 ] || exit 4
|
||||||
if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
|
[ -x $exec ] || exit 5
|
||||||
echo -n $"Setting NIS domain: "
|
DOMAINNAME=`domainname`
|
||||||
if [ -n "$NISDOMAIN" ]; then
|
if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
|
||||||
action $"domain is '$NISDOMAIN' " domainname $NISDOMAIN
|
echo -n $"Setting NIS domain: "
|
||||||
else # See if the domain is set in config file
|
if [ -n "$NISDOMAIN" ]; then
|
||||||
NISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \
|
action $"domain is '$NISDOMAIN' " domainname $NISDOMAIN
|
||||||
awk '{print $2}'`
|
else # See if the domain is set in config file
|
||||||
if [ -n "$NISDOMAIN" ]; then
|
NISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \
|
||||||
action $"domain is '$NISDOMAIN' " \
|
awk '{print $2}'`
|
||||||
domainname $NISDOMAIN
|
if [ -n "$NISDOMAIN" ]; then
|
||||||
else
|
action $"domain is '$NISDOMAIN' " \
|
||||||
action $"domain not found" /bin/false
|
domainname $NISDOMAIN
|
||||||
logger -t ypbind $"domain not found"
|
else
|
||||||
return 1
|
action $"domain not found" /bin/false
|
||||||
fi
|
logger -t ypbind $"domain not found"
|
||||||
fi
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo -n $"Starting NIS service: "
|
fi
|
||||||
selinux_on
|
echo -n $"Starting NIS service: "
|
||||||
daemon ypbind $OTHER_YPBIND_OPTS
|
selinux_on
|
||||||
RETVAL=$?
|
daemon $exec $OTHER_YPBIND_OPTS
|
||||||
echo
|
retval=$?
|
||||||
if [ $RETVAL -ne 0 ]; then
|
echo
|
||||||
#selinux_off
|
if [ $retval -ne 0 ]; then
|
||||||
logger -t ypbind "failed to start!"
|
#selinux_off
|
||||||
return $RETVAL
|
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
|
fi
|
||||||
echo -n $"Binding NIS service: "
|
sleep 2
|
||||||
# the following fixes problems with the init scripts continuing
|
echo -n "."
|
||||||
# even when we are really not bound yet to a server, and then things
|
done
|
||||||
# that need NIS fail.
|
if [ $retval -eq 0 ]; then
|
||||||
timeout=10
|
logger -t ypbind \
|
||||||
firsttime=1
|
"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
|
||||||
SECONDS=0
|
touch $lockfile
|
||||||
while [ $SECONDS -lt $timeout ]; do
|
success
|
||||||
if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind
|
else
|
||||||
then
|
logger -t ypbind \
|
||||||
if [ $firsttime -eq 1 ]; then
|
"NIS server for domain `domainname` is not responding."
|
||||||
# reset timeout
|
failure
|
||||||
timeout=$NISTIMEOUT
|
#selinux_off
|
||||||
firsttime=0
|
retval=100
|
||||||
fi
|
fi
|
||||||
/usr/bin/ypwhich > /dev/null 2>&1
|
echo
|
||||||
RETVAL=$?
|
return $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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo -n $"Shutting down NIS service: "
|
[ $UID -eq 0 ] || exit 4
|
||||||
killproc ypbind
|
[ -x $exec ] || exit 5
|
||||||
RETVAL=$?
|
echo -n $"Shutting down NIS service: "
|
||||||
if [ $RETVAL -eq 0 ]; then
|
killproc $prog
|
||||||
rm -f /var/lock/subsys/ypbind
|
retval=$?
|
||||||
# if we used brute force (like kill -9) we don't want those around
|
echo
|
||||||
if [ x$(domainname) != x ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
rm -f /var/yp/binding/$(domainname)*
|
rm -f $lockfile
|
||||||
fi
|
# 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
|
fi
|
||||||
#selinux_off
|
#selinux_off
|
||||||
return $RETVAL
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
echo -n $"Reloading NIS service: "
|
echo -n $"Reloading NIS service: "
|
||||||
p=`/sbin/pidof -o %PPID 'ypbind'`
|
killproc $prog -HUP
|
||||||
RETVAL=$?
|
retval=$?
|
||||||
if [ "$RETVAL" -eq 0 ]; then
|
echo
|
||||||
/bin/kill -HUP $p
|
return $retval
|
||||||
RETVAL=$?
|
|
||||||
fi
|
|
||||||
[ "$RETVAL" -eq 0 ] && success || failure
|
|
||||||
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.
|
# See how we were called.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
rh_status_q && exit 0
|
||||||
RETVAL=$?
|
$1
|
||||||
if [ $RETVAL -eq 100 ]; then stop; RETVAL=1; fi
|
retval=$?
|
||||||
|
if [ $retval -eq 100 ]; then stop; exit 1; fi
|
||||||
|
exit $retval
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stop
|
rh_status_q || exit 0
|
||||||
RETVAL=$?
|
$1
|
||||||
;;
|
;;
|
||||||
status)
|
restart)
|
||||||
status ypbind
|
$1
|
||||||
RETVAL=$?
|
|
||||||
;;
|
;;
|
||||||
restart)
|
reload)
|
||||||
|
rh_status_q || exit 7
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
force-reload)
|
||||||
|
force_reload
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
rh_status
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
rh_status_q || exit 0
|
||||||
restart
|
restart
|
||||||
RETVAL=$?
|
|
||||||
;;
|
;;
|
||||||
condrestart|try-restart)
|
usage)
|
||||||
if [ -e /var/lock/subsys/ypbind ]; then restart; fi
|
$1
|
||||||
;;
|
;;
|
||||||
reload)
|
*)
|
||||||
reload
|
usage
|
||||||
;;
|
exit 2
|
||||||
force-reload)
|
|
||||||
if ! reload; then restart; fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status}"
|
|
||||||
RETVAL=3
|
|
||||||
esac
|
esac
|
||||||
|
exit $?
|
||||||
exit $RETVAL
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Summary: The NIS daemon which binds NIS clients to an NIS domain
|
Summary: The NIS daemon which binds NIS clients to an NIS domain
|
||||||
Name: ypbind
|
Name: ypbind
|
||||||
Version: 1.31
|
Version: 1.31
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
|
Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
|
||||||
@ -85,6 +85,10 @@ fi
|
|||||||
%doc README NEWS
|
%doc README NEWS
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jan 21 2010 Karel Klic <kklic@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@redhat.com> - 3:1.31-1
|
* Mon Jan 4 2010 Karel Klic <kklic@redhat.com> - 3:1.31-1
|
||||||
- Updated to version 1.31 from upstream
|
- Updated to version 1.31 from upstream
|
||||||
- Removed signalstate patch because it was merged by upstream
|
- Removed signalstate patch because it was merged by upstream
|
||||||
|
Loading…
Reference in New Issue
Block a user