[nsca] rewrite initscript; add support for a sysconfig file
Xavier Bachelot
xavierb at fedoraproject.org
Wed Sep 19 20:47:40 UTC 2012
commit 0a830edd1111de00e8be908c12b340683ca6f651
Author: Xavier Bachelot <xavier at bachelot.org>
Date: Wed Sep 19 22:13:49 2012 +0200
rewrite initscript; add support for a sysconfig file
nsca-initscript | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
nsca-sysconfig | 7 ++++
nsca.spec | 14 ++++++--
3 files changed, 116 insertions(+), 3 deletions(-)
---
diff --git a/nsca-initscript b/nsca-initscript
new file mode 100644
index 0000000..b9a663b
--- /dev/null
+++ b/nsca-initscript
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# nsca Nagios Service Check Acceptor
+#
+# chkconfig: - 80 20
+# description: nsca is a daemon for accepting service check results \
+# from applications running on other hosts.
+# processname: nsca
+# config: /etc/nagios/nsca.cfg
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Check that networking is up.
+[ ${NETWORKING} = "no" ] && exit 0
+
+exec="/usr/sbin/nsca"
+prog="nsca"
+config="/etc/nagios/nsca.cfg"
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+ [ -x $exec ] || exit 5
+ [ -f $config ] || exit 6
+ echo -n $"Starting $prog: "
+ daemon $exec $OPTIONS -c $config
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc nsca
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ killproc $prog -HUP
+}
+
+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
+}
+
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ 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
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/nsca-sysconfig b/nsca-sysconfig
new file mode 100644
index 0000000..0ab48e7
--- /dev/null
+++ b/nsca-sysconfig
@@ -0,0 +1,7 @@
+# This file is used to set NSCA daemon options.
+#
+# Options:
+# --inetd = Run as a service under inetd or xinetd
+# --daemon = Run as a standalone multi-process daemon
+# --single = Run as a standalone single-process daemon (default)
+OPTIONS=""
diff --git a/nsca.spec b/nsca.spec
index 4d22659..22400b3 100644
--- a/nsca.spec
+++ b/nsca.spec
@@ -1,11 +1,13 @@
Summary: Nagios Service Check Acceptor
Name: nsca
Version: 2.9.1
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2+
Group: Applications/System
URL: http://www.nagios.org/
-Source: http://downloads.sourceforge.net/nagios/nsca-%{version}.tar.gz
+Source0: http://downloads.sourceforge.net/nagios/nsca-%{version}.tar.gz
+Source1: nsca-initscript
+Source2: nsca-sysconfig
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Patch0: nsca-2.9-initscript.patch
@@ -61,7 +63,8 @@ install -Dp -m 0755 src/nsca %{buildroot}%{_sbindir}/nsca
install -Dp -m 0755 src/send_nsca %{buildroot}%{_sbindir}/send_nsca
install -Dp -m 0644 sample-config/nsca.cfg %{buildroot}%{_sysconfdir}/nagios/nsca.cfg
install -Dp -m 0644 sample-config/send_nsca.cfg %{buildroot}%{_sysconfdir}/nagios/send_nsca.cfg
-install -Dp -m 0755 init-script %{buildroot}%{_initrddir}/nsca
+install -Dp -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/nsca
+install -Dp -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/nsca
%post
@@ -89,6 +92,7 @@ rm -rf %{buildroot}
%defattr(-,root,root,0755)
%doc Changelog LEGAL README SECURITY
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/nagios/nsca.cfg
+%config(noreplace) %{_sysconfdir}/sysconfig/nsca
%{_initrddir}/nsca
%{_sbindir}/nsca
@@ -102,6 +106,10 @@ rm -rf %{buildroot}
%changelog
+* Mon Sep 01 2012 Xavier Bachelot <xavier at bachelot.org> - 2.9.1-3
+- Add a sysconfig file.
+- Rewrite initscript.
+
* Fri Jul 20 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
More information about the scm-commits
mailing list