Improved initscripts
This commit is contained in:
parent
1ee3ded9aa
commit
c3b633e85f
113
ypserv-2.21-pidfile.patch
Normal file
113
ypserv-2.21-pidfile.patch
Normal file
@ -0,0 +1,113 @@
|
||||
diff -up ypserv-2.21/rpc.ypxfrd/ypxfrd.c.pidfile ypserv-2.21/rpc.ypxfrd/ypxfrd.c
|
||||
--- ypserv-2.21/rpc.ypxfrd/ypxfrd.c.pidfile 2010-01-21 18:07:46.000000000 +0100
|
||||
+++ ypserv-2.21/rpc.ypxfrd/ypxfrd.c 2010-01-21 18:49:27.107770454 +0100
|
||||
@@ -59,6 +59,14 @@
|
||||
#include "log_msg.h"
|
||||
#include "compat.h"
|
||||
|
||||
+#ifdef HAVE_PATHS_H
|
||||
+#include <paths.h>
|
||||
+#endif
|
||||
+#ifndef _PATH_VARRUN
|
||||
+#define _PATH_VARRUN "/etc/"
|
||||
+#endif
|
||||
+#define _YPXFRD_PIDFILE _PATH_VARRUN"ypxfrd.pid"
|
||||
+
|
||||
extern void ypxfrd_freebsd_prog_1(struct svc_req *, SVCXPRT *);
|
||||
|
||||
int _rpcpmstart = 0;
|
||||
@@ -118,6 +126,7 @@ static void
|
||||
sig_quit (int sig UNUSED)
|
||||
{
|
||||
pmap_unset (YPXFRD_FREEBSD_PROG, YPXFRD_FREEBSD_VERS);
|
||||
+ unlink (_YPXFRD_PIDFILE);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -133,6 +142,69 @@ sig_hup (int sig UNUSED)
|
||||
cached_filehandles = 0;
|
||||
}
|
||||
|
||||
+/* Create a pidfile on startup */
|
||||
+static void
|
||||
+create_pidfile (void)
|
||||
+{
|
||||
+ int fd, left, written;
|
||||
+ pid_t pid;
|
||||
+ char pbuf[50], *ptr;
|
||||
+ struct flock lock;
|
||||
+
|
||||
+ fd = open (_YPXFRD_PIDFILE, O_CREAT | O_RDWR,
|
||||
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
+ if (fd < 0)
|
||||
+ {
|
||||
+ log_msg ("cannot create pidfile %s", _YPXFRD_PIDFILE);
|
||||
+ if (debug_flag)
|
||||
+ log_msg ("\n");
|
||||
+ }
|
||||
+
|
||||
+ lock.l_type = F_WRLCK;
|
||||
+ lock.l_start = 0;
|
||||
+ lock.l_whence = SEEK_SET;
|
||||
+ lock.l_len = 0;
|
||||
+
|
||||
+ /* Is the pidfile locked by another ypserv ? */
|
||||
+ if (fcntl (fd, F_GETLK, &lock) < 0)
|
||||
+ {
|
||||
+ log_msg ("fcntl error");
|
||||
+ if (debug_flag)
|
||||
+ log_msg ("\n");
|
||||
+ }
|
||||
+ if (lock.l_type == F_UNLCK)
|
||||
+ pid = 0; /* false, region is not locked by another proc */
|
||||
+ else
|
||||
+ pid = lock.l_pid; /* true, return pid of lock owner */
|
||||
+
|
||||
+ if (0 != pid)
|
||||
+ {
|
||||
+ log_msg ("rpc.ypxfrd already running (pid %d) - exiting", pid);
|
||||
+ if (debug_flag)
|
||||
+ log_msg ("\n");
|
||||
+ exit (1);
|
||||
+ }
|
||||
+
|
||||
+ /* write lock */
|
||||
+ lock.l_type = F_WRLCK;
|
||||
+ lock.l_start = 0;
|
||||
+ lock.l_whence = SEEK_SET;
|
||||
+ lock.l_len = 0;
|
||||
+ if (0 != fcntl (fd, F_SETLK, &lock))
|
||||
+ log_msg ("cannot lock pidfile");
|
||||
+ sprintf (pbuf, "%ld\n", (long) getpid ());
|
||||
+ left = strlen (pbuf);
|
||||
+ ptr = pbuf;
|
||||
+ while (left > 0)
|
||||
+ {
|
||||
+ if ((written = write (fd, ptr, left)) <= 0)
|
||||
+ return; /* error */
|
||||
+ left -= written;
|
||||
+ ptr += written;
|
||||
+ }
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
Usage (int exitcode)
|
||||
{
|
||||
@@ -272,6 +344,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
+ create_pidfile ();
|
||||
+
|
||||
/* Change current directory to database location */
|
||||
if (chdir(path_ypdb) < 0)
|
||||
{
|
||||
@@ -448,6 +522,7 @@ main (int argc, char **argv)
|
||||
|
||||
svc_run();
|
||||
log_msg("svc_run returned");
|
||||
+ unlink (_YPXFRD_PIDFILE);
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# yppasswdd: Starts the yp-passwdd, the YP password changing server
|
||||
# yppasswdd: Starts the YP password changing server
|
||||
#
|
||||
# Version: @(#) /etc/init.d/yppasswdd 1.0
|
||||
#
|
||||
@ -8,18 +8,28 @@
|
||||
# description: yppasswdd is the RPC server that lets users change their \
|
||||
# passwords in the presence of NIS (a.k.a. YP). It must be \
|
||||
# run on the NIS master server for that NIS domain. The client \
|
||||
# program is knwon as yppasswd in most cases.
|
||||
# program is known as yppasswd in most cases.
|
||||
# processname: rpc.yppasswdd
|
||||
#
|
||||
# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
|
||||
# the guidelines document.
|
||||
|
||||
# Source function library.
|
||||
[ -f /etc/rc.d/init.d/functions ] || exit 0
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# getting the YP-Domainname
|
||||
# getting the YP domain name
|
||||
. /etc/sysconfig/network
|
||||
|
||||
execname="rpc.yppasswdd"
|
||||
exec="/usr/sbin/$execname"
|
||||
prog="yppasswdd"
|
||||
|
||||
# Get the settings
|
||||
. /etc/sysconfig/yppasswdd
|
||||
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
pidfile=/var/run/$prog.pid
|
||||
|
||||
if [ "$ETCDIR" ]; then
|
||||
YPPASSWDD_ARGS="$YPPASSWDD_ARGS -D $ETCDIR"
|
||||
@ -33,52 +43,86 @@ if [ "$SHADOWFILE" ]; then
|
||||
YPPASSWDD_ARGS="$YPPASSWDD_ARGS -s $SHADOWFILE"
|
||||
fi
|
||||
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting YP passwd service: "
|
||||
daemon rpc.yppasswdd $YPPASSWDD_ARGS
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/yppasswdd
|
||||
return $RETVAL
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Starting YP passwd service: "
|
||||
daemon --pidfile=$pidfile $exec $YPPASSWDD_ARGS
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping YP passwd service: "
|
||||
killproc rpc.yppasswdd
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/yppasswdd
|
||||
echo
|
||||
return $RETVAL
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Stopping YP passwd service: "
|
||||
killproc -p $pidfile $execname
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status -p $pidfile -l $prog $execname
|
||||
}
|
||||
|
||||
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
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
status)
|
||||
status rpc.yppasswdd
|
||||
RETVAL=$?
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f /var/lock/subsys/yppasswdd ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
||||
exit 1
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
usage)
|
||||
$1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
exit $?
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# ypserv: Starts the yp-server
|
||||
#
|
||||
@ -13,67 +13,113 @@
|
||||
# server, and is not needed on NIS clients.
|
||||
# processname: ypserv
|
||||
# config: /etc/ypserv.conf
|
||||
#
|
||||
# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
|
||||
# the guidelines document.
|
||||
|
||||
# Source function library.
|
||||
[ -f /etc/rc.d/init.d/functions ] || exit 0
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# getting the YP-Domainname
|
||||
. /etc/sysconfig/network
|
||||
# getting the YP domain name
|
||||
[ -e /etc/sysconfig/network ] && . /etc/sysconfig/network
|
||||
|
||||
RETVAL=0
|
||||
exec="/usr/sbin/ypserv"
|
||||
prog="ypserv"
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
|
||||
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
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
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 $"Starting YP server services: "
|
||||
daemon ypserv $YPSERV_ARGS
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ypserv
|
||||
return $RETVAL
|
||||
fi
|
||||
echo -n $"Starting YP server services: "
|
||||
daemon $exec $YPSERV_ARGS
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping YP server services: "
|
||||
killproc ypserv
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ypserv
|
||||
echo
|
||||
return $RETVAL
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Stopping YP server services: "
|
||||
killproc $prog
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading securenets and ypserv.conf file:"
|
||||
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)
|
||||
start
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
status)
|
||||
status ypserv
|
||||
RETVAL=$?
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f /var/lock/subsys/ypserv ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
||||
exit 1
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
usage)
|
||||
$1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
exit $?
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# ypxfrd: Starts the ypxfrd daemon
|
||||
#
|
||||
@ -8,59 +8,108 @@
|
||||
# description: ypxfrd should be started in addition to ypserv to accelerate \
|
||||
# transferring yp maps.
|
||||
# processname: ypxfrd
|
||||
#
|
||||
# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
|
||||
# the guidelines document.
|
||||
|
||||
# Source function library.
|
||||
[ -f /etc/rc.d/init.d/functions ] || exit 0
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# getting the YP-Domainname
|
||||
# getting the YP domain name
|
||||
. /etc/sysconfig/network
|
||||
|
||||
RETVAL=0
|
||||
execname="rpc.ypxfrd"
|
||||
exec="/usr/sbin/$execname"
|
||||
prog="ypxfrd"
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
pidfile=/var/run/$prog.pid
|
||||
|
||||
start() {
|
||||
echo -n $"Starting YP map server: "
|
||||
daemon rpc.ypxfrd $YPXFRD_ARGS
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ypxfrd
|
||||
return $RETVAL
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Starting YP map server: "
|
||||
daemon --pidfile=$pidfile $exec $YPXFRD_ARGS
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping YP map server: "
|
||||
killproc rpc.ypxfrd
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ypxfrd
|
||||
echo
|
||||
return $RETVAL
|
||||
[ $UID -eq 0 ] || exit 4
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Stopping YP map server: "
|
||||
killproc -p $pidfile $execname
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading securenets and ypserv.conf file:"
|
||||
killproc -p $pidfile $execname -HUP
|
||||
retval=$?
|
||||
echo
|
||||
return $retval
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status -p $pidfile -l $prog $execname
|
||||
}
|
||||
|
||||
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
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
status)
|
||||
status rpc.ypxfrd
|
||||
RETVAL=$?
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f /var/lock/subsys/ypxfrd ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
||||
exit 1
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
usage)
|
||||
$1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
exit $?
|
||||
|
17
ypserv.spec
17
ypserv.spec
@ -4,7 +4,7 @@ Summary: The NIS (Network Information Service) server
|
||||
Url: http://www.linux-nis.org/nis/ypserv/index.html
|
||||
Name: ypserv
|
||||
Version: 2.21
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2
|
||||
Group: System Environment/Daemons
|
||||
Source0: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypserv-%{version}.tar.bz2
|
||||
@ -27,6 +27,12 @@ Patch4: ypserv-2.13-ypxfr-zeroresp.patch
|
||||
Patch5: ypserv-2.19-inval-ports.patch
|
||||
Patch6: ypserv-2.13-nonedomain.patch
|
||||
Patch7: ypserv-2.19-slp-warning.patch
|
||||
# Modifies rpc.ypxfrd to create pidfile.
|
||||
# The patch should be modified before sending it to upstream:
|
||||
# create_pidfile() should go to /lib directory, and should be
|
||||
# called by all daemons.
|
||||
# Not sent to upstream.
|
||||
Patch8: ypserv-2.21-pidfile.patch
|
||||
Obsoletes: yppasswd
|
||||
BuildRequires: gdbm-devel
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
@ -57,6 +63,7 @@ machines.
|
||||
%patch5 -p1 -b .ports
|
||||
%patch6 -p1 -b .nonedomain
|
||||
%patch7 -p1 -b .slp-warning
|
||||
%patch8 -p1 -b .pidfile
|
||||
|
||||
%build
|
||||
cp etc/README etc/README.etc
|
||||
@ -142,6 +149,14 @@ exit 0
|
||||
%{_includedir}/*/*
|
||||
|
||||
%changelog
|
||||
* Thu Jan 21 2010 Karel Klic <kklic@redhat.com> - 2.21-2
|
||||
- Added patch for rpc.ypxfrd to create a pid file
|
||||
- Rewrote initscripts to become closer to Packaging:SysVInitScript
|
||||
Fedora guildeline
|
||||
- Fixed initscript for ypserv (rhbz#523438)
|
||||
- Fixed initscript for yppasswdd (rhbz#523394)
|
||||
- Fixed initscript for ypxfrd (rhbz#523397)
|
||||
|
||||
* Wed Jan 13 2010 Karel Klic <kklic@redhat.com> - 2.21-1
|
||||
- Updated to new upstream version
|
||||
- Removed ypserv-2.11-nomap.patch, it has been applied by upstream
|
||||
|
Loading…
Reference in New Issue
Block a user