Add native systemd unit file.

(rhbz#693873)
This commit is contained in:
Honza Horák 2011-04-14 15:26:32 +02:00
parent 7f752920b1
commit 9bfa494533
6 changed files with 192 additions and 241 deletions

View File

@ -0,0 +1,67 @@
diff -up ypbind-mt-1.32/man/ypbind.8.systemd ypbind-mt-1.32/man/ypbind.8
--- ypbind-mt-1.32/man/ypbind.8.systemd 2011-04-14 14:28:24.558085630 +0200
+++ ypbind-mt-1.32/man/ypbind.8 2011-04-14 14:28:24.596085630 +0200
@@ -171,7 +171,7 @@ ypbind \- NIS binding process
.SH "Synopsis"
.fam C
.HP \w'\fBypbind\fR\ 'u
-\fBypbind\fR [\-c] [\-d | \-debug] [\-verbose] [\-broadcast] [\-broken\-server] [\-ypset] [\-ypsetme] [\-no\-ping] [\-f\ \fIconfigfile\fR] [\-local\-only] [\-ping\-interval\ \fIping\-interval\fR] [\-no\-dbus]
+\fBypbind\fR [\-c] [\-d | \-debug] [\-n | \-foreground] [\-verbose] [\-broadcast] [\-broken\-server] [\-ypset] [\-ypsetme] [\-no\-ping] [\-f\ \fIconfigfile\fR] [\-local\-only] [\-ping\-interval\ \fIping\-interval\fR] [\-no\-dbus]
.fam
.fam C
.HP \w'\fBypbind\fR\ 'u
@@ -292,6 +292,12 @@ in debug mode\&.
will not put itself into background, and error messages and debug output are written to standard error\&.
.RE
.PP
+\fB\-foreground\fR
+.RS 4
+\fBypbind\fR
+will not put itself into background\&.
+.RE
+.PP
\fB\-verbose\fR
.RS 4
Causes
@@ -365,6 +371,11 @@ contains the process id of the currently
\fBypbind\fR
master process\&.
.RE
+.PP
+/lib/systemd/system/ypbind\&.service
+.RS 4
+systemd native service file\&.
+.RE
.SH "SEE ALSO"
.PP
diff -up ypbind-mt-1.32/src/ypbind-mt.c.systemd ypbind-mt-1.32/src/ypbind-mt.c
--- ypbind-mt-1.32/src/ypbind-mt.c.systemd 2009-11-19 11:29:00.000000000 +0100
+++ ypbind-mt-1.32/src/ypbind-mt.c 2011-04-14 14:28:24.598085629 +0200
@@ -71,6 +71,7 @@ const char *configfile = "/etc/yp.conf";
int ypset = SET_NO;
int use_broadcast = 0;
int broken_server = 0;
+int foreground_flag = 0;
int ping_interval = 20;
int local_only = 0;
int port = -1;
@@ -688,6 +689,9 @@ main (int argc, char **argv)
else if (strcmp ("-d", argv[i]) == 0 ||
strcmp ("-debug", argv[i]) == 0)
debug_flag = 1;
+ else if (strcmp ("-f", argv[i]) == 0 ||
+ strcmp ("-foreground", argv[i]) == 0)
+ foreground_flag = 1;
else if (strcmp ("-v", argv[i]) == 0 ||
strcmp ("-verbose", argv[i]) == 0)
verbose_flag = 1;
@@ -830,7 +834,7 @@ main (int argc, char **argv)
log_msg (LOG_DEBUG, "[Welcome to ypbind-mt, version %s]\n", VERSION);
log_msg (LOG_DEBUG, "ping interval is %d seconds\n", ping_interval);
}
- else
+ else if (! foreground_flag)
{
int j;

47
ypbind-post-waitbind Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# ypbind-domain
#
# description: This is part of former ypbind init script, which is used
# to fix problems with the init scripts continuing even when
# we are really not bound yet to a server, and then things
# that need NIS fail.
#
# NISTIMEOUT should be a multiple of 15 since
# ypwhich has a hardcoded 15sec timeout
[ -z "$NISTIMEOUT" ] && NISTIMEOUT=45
echo -n $"Binding NIS service: "
timeout=10
firsttime=1
SECONDS=0
retval=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`"
else
logger -t ypbind \
"NIS server for domain `domainname` is not responding."
fi
echo

28
ypbind-pre-setdomain Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
#
# ypbind-domain
#
# description: This is part of former ypbind init script, which is used
# to setup proper domainname before starting ypbind daemon
# itself. If $NISDOMAIN is not defined, it reads config file.
#
OTHER_YPBIND_OPTS=""
DOMAINNAME=`domainname`
if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
echo -n $"Setting NIS domain: "
if [ -n "$NISDOMAIN" ]; then
domainname $NISDOMAIN
else # See if the domain is set in config file
NISDOMAIN=`awk '{ if ($1 == "domain") {print $2; exit} }' /etc/yp.conf`
if [ -n "$NISDOMAIN" ]; then
domainname $NISDOMAIN
else
logger -t ypbind $"domain not found"
fi
fi
fi
echo

View File

@ -1,227 +0,0 @@
#!/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.
### BEGIN INIT INFO
# Provides: ypbind
# Required-Start: $local_fs $remote_fs $network $rpcbind
# Required-Stop: $local_fs $remote_fs $network $rpcbind
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts the ypbind daemon
# 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.
### END INIT INFO
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 0
exec="/usr/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
}
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
}
start() {
[ $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=`awk '{ if ($1 == "domain") {print $2; exit} }' /etc/yp.conf`
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() {
[ $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
}
reload() {
echo -n $"Reloading NIS service: "
killproc $prog -HUP
retval=$?
echo
return $retval
}
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)
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
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
usage)
$1
;;
*)
usage
exit 2
esac
exit $?

12
ypbind.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=The ypbind daemon which binds NIS/YP clients to NIS domain
After=syslog.target network.target rpcbind.service
[Service]
EnvironmentFile=/etc/sysconfig/ypbind
ExecStartPre=/usr/lib/ypbind/ypbind-pre-setdomain ; /usr/sbin/setsebool allow_ypbind=1
ExecStart=/usr/sbin/ypbind -f $OTHER_YPBIND_OPTS
ExecStopPost=/usr/sbin/setsebool allow_ypbind=0 ; /usr/lib/ypbind/ypbind-post-waitbind
[Install]
WantedBy=multi-user.target

View File

@ -1,13 +1,16 @@
Summary: The NIS daemon which binds NIS clients to an NIS domain
Name: ypbind
Version: 1.32
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{version}.tar.bz2
Url: http://www.linux-nis.org/nis/ypbind-mt/index.html
Source1: ypbind.init
Source2: nis.sh
Source3: ypbind.service
Source4: ypbind-pre-setdomain
Source5: ypbind-post-waitbind
# Fedora-specific patch. Renaming 'ypbind' package to proper
# 'ypbind-mt' would allow us to drop it.
Patch1: ypbind-1.11-gettextdomain.patch
@ -15,11 +18,12 @@ Patch1: ypbind-1.11-gettextdomain.patch
Patch2: ypbind-mt-1.32-typo.patch
Patch3: ypbind-mt-1.32-typo2.patch
Patch4: ypbind-mt-1.32-dbus.patch
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
Requires(postun): initscripts
Patch5: ypbind-mt-1.32-systemd.patch
# This is for /bin/systemctl
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires: rpcbind, yp-tools
Epoch: 3
BuildRequires: dbus-glib-devel, docbook-style-xsl
@ -47,6 +51,7 @@ also need to install the ypserv package to a machine on your network.
%patch2 -p1 -b .typo
%patch3 -p1 -b .typo2
%patch4 -p1 -b .dbus
%patch5 -p1 -b .systemd
%build
%configure --enable-dbus-nm
@ -56,38 +61,57 @@ make
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_initrddir} $RPM_BUILD_ROOT/var/yp/binding $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/
mkdir -p $RPM_BUILD_ROOT/var/yp/binding $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/ $RPM_BUILD_ROOT/lib/systemd/system/ $RPM_BUILD_ROOT/usr/lib/%{name}/
install -m 644 etc/yp.conf $RPM_BUILD_ROOT/etc/yp.conf
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/ypbind
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/dhcp/dhclient.d/nis.sh
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/lib/systemd/system/ypbind.service
install -m 755 %{SOURCE4} $RPM_BUILD_ROOT/usr/lib/%{name}/ypbind-pre-setdomain
install -m 755 %{SOURCE5} $RPM_BUILD_ROOT/usr/lib/%{name}/ypbind-post-waitbind
%{find_lang} %{name}
%post
/sbin/chkconfig --add ypbind
# Package install, not upgrade
if [ $1 -eq 1 ]; then
/bin/systemctl enable %{name}.service || :
fi
# Package with native systemd unit file is installed for the first time
%triggerun -- ypbind < 3:1.32-9
if /sbin/chkconfig --level 3 ypbind ; then
/bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || :
fi
%preun
if [ $1 = 0 ] ; then
/sbin/service ypbind stop >/dev/null 2>&1
/sbin/chkconfig --del ypbind
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
fi
%postun
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge "1" ] ; then
/sbin/service ypbind condrestart >/dev/null 2>&1 || :
# Package upgrade, not uninstall
/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
%files -f %{name}.lang
%defattr(-,root,root)
%{_sbindir}/*
%{_mandir}/*/*
%{_initrddir}/*
/usr/lib/%{name}/*
/lib/systemd/system/*
/etc/dhcp/dhclient.d/*
%config(noreplace) /etc/yp.conf
%dir /var/yp/binding
%doc README NEWS COPYING
%changelog
* Wed Apr 14 2011 Honza Horak <hhorak@redhat.com> - 3:1.32-9
- Add native systemd unit file.
(rhbz#693873)
* Thu Apr 14 2011 Honza Horak <hhorak@redhat.com> - 3:1.32-8
- Added rpcbind to LSB header in SysV init file.