--- create_monit_ssl.sh.orig
+++ create_monit_ssl.sh
@@ -1,10 +1,10 @@
 #!/bin/bash
 openssl genrsa \
--out /etc/monit_ssl_key.pem 1024
+-out /etc/monit.ssl/monit_ssl_key.pem 1024
 openssl req -batch -new \
--key /etc/monit_ssl_key.pem \
--out /etc/monit_ssl_cert.csr
+-key /etc/monit.ssl/monit_ssl_key.pem \
+-out /etc/monit.ssl/monit_ssl_cert.csr
 openssl x509 -req -days 999 \
--in /etc/monit_ssl_cert.csr \
--signkey /etc/monit_ssl_key.pem \
--out /etc/monit_ssl_cert.pem
+-in /etc/monit.ssl/monit_ssl_cert.csr \
+-signkey /etc/monit.ssl/monit_ssl_key.pem \
+-out /etc/monit.ssl/monit_ssl_cert.pem
--- mmonit.pem.orig
+++ mmonit.pem
@@ -1,49 +1,16 @@
------BEGIN PRIVATE KEY-----
-MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCgUoOW4FGza/q
-7Tj0rF2PzCmBM3uhL+dfUYWBLL9yBvbyfG7J5VV+4VIdjLjW7pm0uF4p1EwgBbOd
-OgYCeydtjH/VD8y8Xj98RQYv3ZhjDd8LRiUTh6YIY4n4MKbhxpA8Oy6nfvku5wo5
-re0Em4SpAN4M9DLIjslpRzuLE8XEpzpbuJHz/uaTz0rC0326BILFCjLWJoa5RANK
-YdGmfDDcRj7G3wbe42j20MwoFZjLRLQr8oz4lrLJMPxMrF88+Kq75HmzhzO06cUh
-LfzjMthE3TeuIEq2lnHApcRO2WwZ9pfX/Hqo4+4QEM5Tf15v82jjFlP2tHQsXOl/
-8c551QDHAgMBAAECggEAT65niDo0W60nxDYqfxGdwqsA1c0heIcHYiUjbCfIxg3U
-XMJdIJiyzafA3BoqHuLgVQiyirBN/1BWpLKAg8OwA1DrjX1Lgl+Z4m7kefdt1iZ4
-mUXDKp0Hh6g/fU1xEE0oCYS1OCjsLCq6Jab60khjsFiKnwPrSf40xMxJuFABVO31
-CxSEgDvAyDdM+Ev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QUEST-----
--- monit-default-config-name.patch.orig
+++ monit-default-config-name.patch
@@ -1,9 +1,9 @@
---- monitor.h.renamed_config	2008-12-07 01:15:10.000000000 +0100
-+++ monitor.h	2008-12-07 01:15:19.000000000 +0100
-@@ -71,7 +71,7 @@
+--- src/monit.h	2013-08-27 23:35:08.000000000 +0200
++++ src/monit.h	2013-11-12 16:16:10.957662500 +0100
+@@ -87,7 +87,7 @@
+ #include "util/StringBuffer.h"
  
  
- #define VERSION            PACKAGE_VERSION
 -#define MONITRC            "monitrc"
 +#define MONITRC            "monit.conf"
  #define TIMEFORMAT         "%Z %b %e %T"
--- monit.spec.orig
+++ monit.spec
@@ -1,5 +1,5 @@
 Name:           monit
-Version:        5.6
+Version:        5.8.1
 Release:        99ix
 Summary:        Manages and monitors processes, files, directories and devices
 
@@ -10,6 +10,9 @@ Source0:        http://www.tildeslash.co
 Source1:        monit-sysv-initscript
 Source2:        monit.logrotate
 Source3:	create_monit_ssl.sh
+Source4:	stunnel-check
+Source5:	ix-monit.conf
+Source7:	monit-logging-conf
 Patch0:         monit-default-config-name.patch
 Patch1:         monit-no-startup-msg.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-root
@@ -20,6 +23,7 @@ BuildRequires:  pam-devel
 BuildRequires:  byacc
 BuildRequires:  gcc, make
 BuildRequires:  pam-devel
+Requires:	make
 
 %description
 monit is a utility for managing and monitoring, processes, files, directories
@@ -28,7 +32,7 @@ and can execute meaningful causal action
 
 %prep
 %setup -q
-#%patch0 -b .confname
+%patch0 -b .confname
 #%patch1 -b .nomsg
 
 %build
@@ -40,7 +44,8 @@ rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
 
 install -p -D -m0755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/monit
-install -p -D -m0600 monitrc $RPM_BUILD_ROOT%{_sysconfdir}/monit.conf
+install -p -D -m0600 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/monit.conf
+install -p -D -m0755 %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/monit.d/logging.conf
 install -p -D -m0755 monit $RPM_BUILD_ROOT%{_bindir}/monit
 install -p -D -m0755 %{SOURCE3} $RPM_BUILD_ROOT%{_bindir}/create_monit_ssl
 
@@ -51,15 +56,6 @@ install -m0600 /dev/null $RPM_BUILD_ROOT
 
 # Let's include some good defaults
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/monit.d
-echo "
-# set daemon mode timeout to 1 minute
-set daemon 60
-# Include all files from %{_sysconfdir}/monit.d/
-include %{_sysconfdir}/monit.d/*" >> $RPM_BUILD_ROOT%{_sysconfdir}/monit.conf
-
-echo "# log to monit.log
-set logfile /var/log/monit
-" > $RPM_BUILD_ROOT%{_sysconfdir}/monit.d/logging
 
 
 %clean
@@ -69,12 +65,34 @@ rm -rf $RPM_BUILD_ROOT
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add monit
 
+exec > /dev/null 2> /dev/null
+if [ ! -f %{_sysconfdir}/pki/tls/certs/monit.pem ] ; then
+pushd %{_sysconfdir}/pki/tls/certs
+umask 077
+cat << EOF | make monit.pem
+--
+Bavaria
+Regensburg
+Monit Default Cert
+IX Tech
+localhost.localdomain
+root@localhost.localdomain
+EOF
+chown root:root monit.pem
+chmod 600 monit.pem
+popd
+fi
+exit 0
+
+
+
 %preun
 if [ $1 = 0 ]; then
         /sbin/service monit stop >/dev/null 2>&1
         /sbin/chkconfig --del monit
 fi
 
+
 %postun
 if [ "$1" -ge "1" ]; then
         /sbin/service monit condrestart >/dev/null 2>&1 || :
@@ -85,7 +103,9 @@ fi
 %defattr(-,root,root,-)
 %doc COPYING README 
 %config(noreplace) %{_sysconfdir}/monit.conf
-%config(noreplace) %{_sysconfdir}/monit.d/logging
+%config(noreplace) %{_sysconfdir}/monit.d/logging.conf
+#%config(noreplace) %{_sysconfdir}/monit.d/ix-monit.conf
+#%config(noreplace) %{_sysconfdir}/monit.ssl/*
 %config(noreplace) %{_sysconfdir}/logrotate.d/monit
 %ghost %{_localstatedir}/log/monit
 %{_sysconfdir}/monit.d/
