[shinken] el6 compatiblity

david hannequin hvad at fedoraproject.org
Sun Sep 23 17:43:03 UTC 2012


commit 4d59dce7784e264885b012699976e1d80c72f79b
Author: hvad <david.hannequin at gmail.com>
Date:   Sun Sep 23 19:42:46 2012 +0200

    el6 compatiblity

 shinken-arbiter.init     |   99 +++++++++++++++++
 shinken-broker.init      |  100 +++++++++++++++++
 shinken-poller.init      |  104 ++++++++++++++++++
 shinken-reactionner.init |  100 +++++++++++++++++
 shinken-receiver.init    |   99 +++++++++++++++++
 shinken-scheduler.init   |  100 +++++++++++++++++
 shinken.spec             |  265 ++++++++++++++++++++++++++++++----------------
 7 files changed, 775 insertions(+), 92 deletions(-)
---
diff --git a/shinken-arbiter.init b/shinken-arbiter.init
new file mode 100644
index 0000000..56e3249
--- /dev/null
+++ b/shinken-arbiter.init
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# shinken-arbiter - Startup script for the Shinken Arbiter Daemon
+#
+# chkconfig: - 20 80
+# description:  Shinken is a monitoring tool and the Arbiter \
+#               is one of its daemon. This one reads the configuration, \
+#               cuts it into parts and dispatches it. Then it waits \
+#               for orders from the users to dispatch them too.
+
+### BEGIN INIT INFO
+# Provides:          shinken-arbiter
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start:    
+# Should-Stop: 
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Shinken arbiter daemon
+# Description:       Shinken is a monitoring tool and the Arbiter
+#                    is one of its daemon. This one reads the configuration,
+#                    cuts it into parts and dispatches it. Then it waits
+#                    for orders from the users to dispatch them too.
+### END INIT INFO
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/nagios.cfg -c /etc/shinken/shinken-specific.cfg"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/arbiterd.pid
+
+exec="/usr/sbin/shinken-arbiter"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken-broker.init b/shinken-broker.init
new file mode 100644
index 0000000..1da5475
--- /dev/null
+++ b/shinken-broker.init
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# shinken-broker - Startup script for the Shinken Broker Daemon
+#
+# chkconfig: 2345 20 80
+# Description:  Shinken is a monitoring tool and the Broker \
+#               is one of its daemon. This one gets the configuration \
+#               from the arbiter. His purpose is to get the broks from \
+#               the schedulers specified in the configuration.
+
+### BEGIN INIT INFO
+# Provides:          shinken-broker
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start:    
+# Should-Stop: 
+# Default-Start:     2 3 4 5 
+# Default-Stop:      0 1 6
+# Short-Description: Shinken broker daemon
+# Description:       Shinken is a monitoring tool and the Broker
+#                    is one of its daemon. This one gets the configuration 
+#                    from the arbiter. His purpose is to get the broks from 
+#                    the schedulers specified in the configuration
+### END INIT INFO
+
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/brokerd.ini"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/brokerd.pid
+
+exec="/usr/sbin/shinken-broker"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken-poller.init b/shinken-poller.init
new file mode 100644
index 0000000..057b081
--- /dev/null
+++ b/shinken-poller.init
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# shinken-poller - Startup script for the Shinken Poller Daemon
+#
+# chkconfig: 2345 20 80
+# description:  Shinken is a monitoring tool and the Poller \
+#               is one of its daemon. This one gets the \
+#               configuration from the arbiter his purpose \ 
+#               is to actually do the checks ordered by the \
+#               schedulers, and then sends the results to \
+#               the schedulers specified in the configuration \
+
+### BEGIN INIT INFO
+# Provides:          shinken-poller
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start: 
+# Should-Stop: 
+# Default-Start:     2 3 4 5 
+# Default-Stop:      0 1 6
+# Short-Description: Shinken poller daemon
+# Description:     Shinken is a monitoring tool and the Poller 
+#                  is one of its daemon. This one gets the 
+#                  configuration from the arbiter his purpose  
+#                  is to actually do the checks ordered by the 
+#                  schedulers, and then sends the results to 
+#                  the schedulers specified in the configuration 
+
+### END INIT INFO
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/pollerd.ini"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/pollerd.pid
+
+exec="/usr/sbin/shinken-poller"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken-reactionner.init b/shinken-reactionner.init
new file mode 100644
index 0000000..bc24653
--- /dev/null
+++ b/shinken-reactionner.init
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# shinken-reactionner - Startup script for the Shinken Reactionner Daemon
+#
+# chkconfig: 2345 20 80
+# description:  Shinken is a monitoring tool and the Reactionner \
+#               is one of its daemon. This one gets the configuration \
+#		from the arbiter His purpose is to get the actually \
+#		do the actions like sending an email ordered by the \
+#		schedulers specified in the configuration. \
+
+### BEGIN INIT INFO
+# Provides:          shinken-reactionner
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start:    
+# Should-Stop: 
+# Default-Start:     2 3 4 5 
+# Default-Stop:      0 1 6
+# Short-Description: Shinken reactionner daemon
+# Description:       Shinken is a monitoring tool and the Reactionner
+#                    is one of its daemon. This one gets the configuration from the arbiter
+#                    His purpose is to get the actually do the actions like sending an email
+#                    ordered by the schedulers specified in the configuration
+### END INIT INFO
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/reactionnerd.ini"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/reactionnerd.pid
+
+exec="/usr/sbin/shinken-reactionner"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken-receiver.init b/shinken-receiver.init
new file mode 100644
index 0000000..3590ed4
--- /dev/null
+++ b/shinken-receiver.init
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# shinken-receiver - Startup script for the Shinken Receiver Daemon
+#
+# chkconfig: 2345 20 80
+# description:  Shinken is a monitoring tool and the Receiver \
+#               is one of its daemon. This one gets the configuration \
+#               from the arbiter His purpose is to get the broks from \
+#               the schedulers specified in the configuration.
+
+### BEGIN INIT INFO
+# Provides:          shinken-receiver
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start:    
+# Should-Stop: 
+# Default-Start:     2 3 4 5 
+# Default-Stop:      0 1 6
+# Short-Description: Shinken receiver daemon
+# Description:       Shinken is a monitoring tool and the Receiver
+#                    is one of its daemon. This one gets the configuration from the arbiter
+#                    His purpose is to get the broks from the schedulers specified in the
+#                    configuration
+### END INIT INFO
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/receiverd.ini"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/receiverd.pid
+
+exec="/usr/sbin/shinken-receiver"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken-scheduler.init b/shinken-scheduler.init
new file mode 100644
index 0000000..16c0460
--- /dev/null
+++ b/shinken-scheduler.init
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# shinken-scheduler - Startup script for the Shinken Scheduler Daemon
+#
+# chkconfig: 2345 20 80
+# description:  Shinken is a monitoring tool and the Scheduler \
+#               is one of its daemon. This one get configuration \
+#		from the arbiter His purpose is only to schedule \
+#		do the checks and actions specified in the \
+#		configuration received from the arbiter. 
+
+### BEGIN INIT INFO
+# Provides:          shinken-scheduler
+# Required-Start:    $all 
+# Required-Stop:     $all
+# Should-Start:    
+# Should-Stop: 
+# Default-Start:     2 3 4 5 
+# Default-Stop:      0 1 6
+# Short-Description: Shinken scheduler daemon
+# Description:       Shinken is a monitoring tool and the Scheduler
+#                    is one of its daemon. This one get configuration from the arbiter
+#                    His purpose is only to schedule do the checks and actions specified
+#                    in the configuration received from the arbiter
+### END INIT INFO
+
+
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+
+daemon_args="-d -c /etc/shinken/schedulerd.ini"             # Arguments to run the daemon with
+pidfile=/var/run/shinken/schedulerd.pid
+
+exec="/usr/sbin/shinken-scheduler"
+prog=$(basename $exec)
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+
+    directory=$(dirname $pidfile)                                                                                                                                    
+    [ ! -d $directory ] && mkdir -p $directory
+    chown nagios:root $directory
+
+    echo -n $"Starting $prog: "
+    $exec $daemon_args
+    # if not running, start it up here, usually something like "daemon $exec"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile}
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+case "$1" in
+    start|stop|restart)
+        $1
+        ;;
+    force-reload)
+        restart
+        ;;
+    status)
+        status $prog
+        ;;
+    try-restart|condrestart)
+        if status $prog >/dev/null ; then
+            restart
+        fi
+	;;
+    reload)
+        # If config can be reloaded without restarting, implement it here,
+        # remove the "exit", and add "reload" to the usage message below.
+        # For example:
+        # status $prog >/dev/null || exit 7
+        # killproc $prog -HUP
+        action $"Service ${0##*/} does not support the reload action: " /bin/false
+        exit 3
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+        exit 2
+esac
diff --git a/shinken.spec b/shinken.spec
index 35510ca..a48d902 100644
--- a/shinken.spec
+++ b/shinken.spec
@@ -1,28 +1,47 @@
+%global with_systemd 0%{?fedora} >= 17
+%global shinken_user nagios
+%global shinken_group nagios
+
 Summary:        Python Monitoring tool
 Name:           shinken
 Version:        1.0.1
-Release:        4%{?dist}
+Release:        5%{?dist}
 URL:            http://%{name}-monitoring.org
 Source0:        http://%{name}-monitoring.org/pub/%{name}-%{version}.tar.gz
 Source1:        shinken-admin.8shinken
 Source2:        shinken.commands.cfg
+Source3:        shinken-arbiter.init
+Source4:        shinken-scheduler.init
+Source5:        shinken-poller.init
+Source6:        shinken-broker.init
+Source7:        shinken-reactionner.init
+Source8:        shinken-receiver.init
 Patch0:         %{name}-build.patch
 License:        AGPLv3+
 Requires:       python 
 Requires:       python-pyro 
 Requires:       python-simplejson 
-Requires:       systemd-units
+%if %{with_systemd}
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else
+Requires(post):  chkconfig
+Requires(preun): chkconfig
+# This is for /sbin/service
+Requires(preun): initscripts
+%endif
 Requires:       nmap 
 Requires:       sudo  
 BuildRequires:  python-devel
 BuildRequires:  python-setuptools
+%if %{with_systemd}
 BuildRequires:  systemd-units
+%endif
+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-buildroot
 Buildarch:      noarch
 
-%global shinken_user nagios
-%global shinken_group nagios
-
 %description 
 Shinken is a new monitoring tool written in Python. 
 The main goal of Shinken is to allow users to have a fully flexible 
@@ -92,7 +111,7 @@ rm  etc/packs/databases/mongodb/macros.cfg
 
 %build
 
-CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build 
+%{__python} setup.py build 
 
 %install
 
@@ -122,13 +141,23 @@ install -p -m0644 for_fedora/etc/{brokerd,pollerd,reactionnerd,receiverd,schedul
 
 cp -rf %{SOURCE2}  %{buildroot}%{_sysconfdir}/%{name}/commands.cfg
 
-install -d -m0755 %{buildroot}%{_unitdir}
-install -p -m0644 for_fedora/systemd/%{name}-arbiter.service %{buildroot}%{_unitdir}/%{name}-arbiter.service
-install -p -m0644 for_fedora/systemd/%{name}-broker.service %{buildroot}%{_unitdir}/%{name}-broker.service
-install -p -m0644 for_fedora/systemd/%{name}-reactionner.service %{buildroot}%{_unitdir}/%{name}-reactionner.service
-install -p -m0644 for_fedora/systemd/%{name}-scheduler.service %{buildroot}%{_unitdir}/%{name}-scheduler.service
-install -p -m0644 for_fedora/systemd/%{name}-receiver.service %{buildroot}%{_unitdir}/%{name}-receiver.service
-install -p -m0644 for_fedora/systemd/%{name}-poller.service %{buildroot}%{_unitdir}/%{name}-poller.service
+%if %{with_systemd}
+  install -d -m0755 %{buildroot}%{_unitdir}
+  install -p -m0644 for_fedora/systemd/%{name}-arbiter.service %{buildroot}%{_unitdir}/%{name}-arbiter.service
+  install -p -m0644 for_fedora/systemd/%{name}-broker.service %{buildroot}%{_unitdir}/%{name}-broker.service
+  install -p -m0644 for_fedora/systemd/%{name}-reactionner.service %{buildroot}%{_unitdir}/%{name}-reactionner.service
+  install -p -m0644 for_fedora/systemd/%{name}-scheduler.service %{buildroot}%{_unitdir}/%{name}-scheduler.service
+  install -p -m0644 for_fedora/systemd/%{name}-receiver.service %{buildroot}%{_unitdir}/%{name}-receiver.service
+  install -p -m0644 for_fedora/systemd/%{name}-poller.service %{buildroot}%{_unitdir}/%{name}-poller.service
+%else
+  install -d -m0755 %{buildroot}%{_initrddir}
+  cp %{SOURCE3} %{buildroot}%{_initrddir}/%{name}-arbiter
+  cp %{SOURCE4} %{buildroot}%{_initrddir}/%{name}-scheduler
+  cp %{SOURCE5} %{buildroot}%{_initrddir}/%{name}-poller
+  cp %{SOURCE6} %{buildroot}%{_initrddir}/%{name}-broker
+  cp %{SOURCE7} %{buildroot}%{_initrddir}/%{name}-reactionner
+  cp %{SOURCE8} %{buildroot}%{_initrddir}/%{name}-receiver
+%endif
 
 install -d -m0755 %{buildroot}%{_sysconfdir}/logrotate.d
 install -p -m0644 for_fedora/%{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/shinken
@@ -150,44 +179,11 @@ install -d -m0755 %{buildroot}%{_mandir}/man3
 install -p -m0644 doc/man/* %{buildroot}%{_mandir}/man3
 install -p -m0644 %{SOURCE1} %{buildroot}%{_mandir}/man3
 
-chmod +x %{buildroot}%{python_sitelib}/%{name}/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/daemons/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/dummy_poller.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/objects/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/livestatus_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/status_dat_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/service_perfdata_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/merlindb_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/host_perfdata_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/couchdb_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/ndodb_oracle_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/ndodb_mysql_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/login/login.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/webui_broker/*.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/action/action.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/bottle.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/clients/livestatus.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/thrift_command_query.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/eltdetail/eltdetail.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/threedimpacts/threedimpacts.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/thrift_query.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/livestatus_broker/mapping.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/thrift_broker.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/depgraph/depgraph.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/thrift_status.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/misc/{regenerator.py,datamanager.py,filter.py,sorter.py,perfdata.py}
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/thrift_response.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/problems/problems.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/thrift_broker/__init__.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/glpidb_broker/__init__.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/glpidb_broker/glpidb_broker.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/dashboard/dashboard.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/system/system.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/mobile/mobile.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/impacts/impacts.py
-chmod +x %{buildroot}%{python_sitelib}/%{name}/modules/ip_tag_arbiter/{__init__.py,ip_tag_arbiter.py}
+for lib in %{buildroot}%{python_sitearch}/%{name}/*.py; do
+ sed '/\/usr\/bin\/env/d' $lib > $lib.new &&
+ touch -r $lib $lib.new &&
+ mv $lib.new $lib
+done
 
 chmod -x %{buildroot}%{python_sitelib}/%{name}/{property,daemon,basemodule}.py
 chmod -x %{buildroot}%{python_sitelib}/%{name}/webui/plugins/eltdetail/htdocs/js/domtab.js
@@ -222,7 +218,6 @@ rm -rf %{buildroot}%{_sbindir}/%{name}-skonf
 rm -rf %{buildroot}%{_usr}/lib/%{name}/plugins/*.{pyc,pyo}
 rm -rf %{buildroot}%{_sbindir}/shinken-{arbiter,discovery,broker,poller,reactionner,receiver,scheduler}.py
 
-
 sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/modules/ip_tag_arbiter/{__init__,ip_tag_arbiter}.py
 sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/misc/{filter,sorter,perfdata}.py
 sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/modules/glpi_arbiter.py
@@ -230,170 +225,250 @@ sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/mis
 sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/webui/plugins/system/system.py
 sed -i -e '1d;2i#!/usr/bin/env python' %{buildroot}%{python_sitelib}/%{name}/webui/plugins/mobile/mobile.py
 
-
-
 %clean
 
 %pre 
-echo Adding %{shinken_group} group ...
 getent group %{shinken_group} >/dev/null || groupadd -r %{shinken_group}
-echo Adding %{shinken_user} user ...
 getent passwd %{shinken_user} >/dev/null || useradd -r -g %{shinken_group} -d %{_localstatedir}/spool/nagios -s /sbin/nologin %{shinken_user}
 exit 0
 
 %post arbiter
+# Initial installation 
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-arbiter || :
+  %endif
 fi
 
 %post broker
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-broker || :
+%endif
 fi
 
 %post poller
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-poller || :
+  %endif
 fi
 
 %post reactionner
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-reactionner || :
+%endif
 fi
 
 %post scheduler
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-scheduler || :
+  %endif
 fi
 
 %post receiver
 if [ $1 -eq 1 ] ; then 
-    # Initial installation 
+  %if %{with_systemd}
     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  %else
+    /sbin/chkconfig --add %{name}-scheduler || :
+  %endif
 fi
 
 %preun arbiter 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-arbiter.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-arbiter.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-arbiter stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-arbiter || :
+  %endif
 fi
 
 %preun broker 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-broker.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-broker.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-broker stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-broker || :
+  %endif
 fi
 
 %preun poller 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-poller.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-poller.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-poller stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-poller || :
+  %endif
 fi
 
 %preun reactionner 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-reactionner.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-reactionner.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-reactionner stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-reactionner || :
+  %endif
 fi
 
 %preun scheduler 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-scheduler.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-scheduler.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-scheduler stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-scheduler || :
+  %endif
 fi
 
 %preun receiver 
 if [ $1 -eq 0 ] ; then
-    # Package removal, not upgrade
+  %if %{with_systemd}
     /bin/systemctl --no-reload disable %{name}-receiver.service > /dev/null 2>&1 || :
     /bin/systemctl stop %{name}-receiver.service > /dev/null 2>&1 || :
+  %else
+    /sbin/service %{name}-scheduler stop > /dev/null 2>&1 || :
+    /sbin/chkconfig --del %{name}-scheduler || :
+  %endif
 fi
 
 %postun arbiter
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-arbiter.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %postun broker
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-broker.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %postun poller
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-poller.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %postun reactionner
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-reactionner.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %postun scheduler
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-scheduler.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %postun receiver
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
+%if %{with_systemd}
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart %{name}-receiver.service >/dev/null 2>&1 || :
-fi
+  fi
+%endif
 
 %files arbiter
-%{_unitdir}/%{name}-arbiter.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-arbiter.service
+%else
+  %{_initrddir}/%{name}-arbiter
+%endif
 %{_sbindir}/%{name}-arbiter*
 %{_mandir}/man3/%{name}-arbiter*
 
 %files reactionner
-%{_unitdir}/%{name}-reactionner.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-reactionner.service
+%else
+  %{_initrddir}/%{name}-reactionner
+%endif
 %{_sbindir}/%{name}-reactionner*
 %{_mandir}/man3/%{name}-reactionner*
 
 %files scheduler
-%{_unitdir}/%{name}-scheduler.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-scheduler.service
+%else
+  %{_initrddir}/%{name}-scheduler
+%endif
 %{_sbindir}/%{name}-scheduler*
 %{_mandir}/man3/%{name}-scheduler*
 
 %files poller
-%{_unitdir}/%{name}-poller.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-poller.service
+%else
+  %{_initrddir}/%{name}-poller
+%endif
 %{_sbindir}/%{name}-poller*
 %{_mandir}/man3/%{name}-poller*
 
 %files broker
-%{_unitdir}/%{name}-broker.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-broker.service
+%else
+  %{_initrddir}/%{name}-broker
+%endif
 %{_sbindir}/%{name}-broker*
 %{_mandir}/man3/%{name}-broker*
 
 %files receiver
-%{_unitdir}/%{name}-receiver.service
+%if %{with_systemd}
+  %{_unitdir}/%{name}-receiver.service
+%else
+  %{_initrddir}/%{name}-receiver
+%endif
 %{_sbindir}/%{name}-receiver*
 %{_mandir}/man3/%{name}-receiver*
 
 %files
 %{python_sitelib}/%{name}
+%if %{with_systemd}
 %{python_sitelib}/Shinken-1.0.1-py2.7.egg-info
+%else
+%{python_sitelib}/Shinken-1.0.1-py2.6.egg-info
+%endif
+%{_sbindir}/%{name}-receiver*
 %{_sbindir}/%{name}-discovery
 %{_sbindir}/%{name}-admin
 %doc etc/packs COPYING THANKS 
@@ -407,6 +482,12 @@ fi
 %attr(-,%{shinken_user} ,%{shinken_group}) %dir %{_localstatedir}/run/%{name}
 
 %changelog
+* Sun Sep 16 2012 David Hannequin <david.hannequin at gmail.com> - 1.0.1-5
+- Add support of el6.
+- Remove shebang from Python libraries.
+- Delete echo printing.
+- Remove CFLAGS.
+
 * Mon Sep 10 2012 David Hannequin <david.hannequin at gmail.com> - 1.0.1-4
 - Add COPYING README THANKS file.
 - delete defattr.


More information about the scm-commits mailing list