From ddff8b45ab496434fe4e4b510f3b364d32c6bb52 Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Thu, 25 Oct 2007 14:17:47 +0000 Subject: [PATCH] r13: - add postgrey + asterisk - register via cp-update into /etc/init.d/monit and gracefully exit with errmsg since we use inittab - deregister from /etc/init.d/monit when purging/deinstalling - document a bit better --- README.CARNet | 23 +++++++++++++++-------- debian/changelog | 10 ++++++++++ debian/postinst | 42 +++++++++++++++++++++++++++++++----------- debian/postrm | 5 +++++ monit-cn/asterisk.conf | 5 +++++ monit-cn/mysqld.conf | 5 ++++- monit-cn/postgrey.conf | 8 ++++++++ 7 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 monit-cn/asterisk.conf create mode 100644 monit-cn/postgrey.conf diff --git a/README.CARNet b/README.CARNet index a62b17e..9634108 100644 --- a/README.CARNet +++ b/README.CARNet @@ -12,15 +12,22 @@ je: Naredba je neinteraktivna i moze se pokretati nakon instalacije novih servisa. Receni program ce skopirati samo predloske za koje postoji -odgovarajuci servis koji ispravno radi. +odgovarajuci servis koji ispravno radi. Takodjer, naredba ce restartati +monit servis ako je aktivan. Za sljedece servise dolaze gotovi predlosci: - amavisd.conf clamd.conf monitrc qpopper.conf thttpd.conf - aosi.conf cron.conf mysqld.conf samba.conf tomcat5.conf - apache1.conf dhcpd3.conf ntpd.conf sendmail.conf vsftpd.conf - apache2.conf dovecot.conf openldap.conf sophie.conf - bind8.conf exim.conf postfix.conf sshd.conf - bind9.conf freeradius.conf proftpd.conf syslogd.conf + amavisd.conf bind9.conf freeradius.conf proftpd.conf syslogd.conf + aosi.conf clamd.conf mysqld.conf qpopper.conf thttpd.conf + apache1.conf cron.conf ntpd.conf samba.conf tomcat5.conf + apache2.conf dhcpd3.conf openldap.conf sendmail.conf vsftpd.conf + asterisk.conf dovecot.conf postfix.conf sophie.conf + bind8.conf exim.conf postgrey.conf sshd.conf - -- Dinko Korunic at Mon, 24 Sep 2007 18:51:14 +0200 +Primijetite da je monit respawnable proces -- on ne starta kroz +/etc/init.d/monit skripte (tzv. System V init skripte), vec kroz +/etc/inittab pri cemu ima poseban status. U slucaju da monit proces +"padne" ili ga nehotice netko "ubije", on ce se automatski odmah pokrenuti +nazad. + + -- Dinko Korunic at Thu, 25 Oct 2007 12:06:37 +0200 diff --git a/debian/changelog b/debian/changelog index 5ca8c19..eb7617b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +monit-cn (1:4.5-2) stable; urgency=low + + * dodan postgrey servis + * rijesen minorni problem sa mysql konfiguracijom (Monit iz Sargea nema + protocol mysql, pa cemo koristiti type tcp) + * workaround za monit SystemV skriptu -- registriramo se na pocetak init + skripte i javljamo da se koristi inittab + + -- Dinko Korunic Thu, 25 Oct 2007 12:01:46 +0200 + monit-cn (1:4.5-1) stable; urgency=low * inicijalni paket sa skriptama za detekciju aktivnih servisa i generiranje diff --git a/debian/postinst b/debian/postinst index e387901..e665ab6 100755 --- a/debian/postinst +++ b/debian/postinst @@ -47,23 +47,42 @@ if [ $installfile -eq 1 ]; then chmod u=rw,go= /etc/monit/monitrc fi -# generate monit.d files -update-monit.d +# (re)generate monit.d files +update-monit.d || true # disable monit startup cp_check_and_sed '^startup=1/#startup=1/g' /etc/default/monit \ || true +# systemv part +echo "CN: Disabling monit SystemV script" +if [ -x "/etc/init.d/monit" ]; then + update-rc.d -f monit remove >/dev/null 2>&1 + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d monit stop || true + else + /etc/init.d/monit stop || true + fi +fi +if [ -e "/etc/init.d/monit" ]; then + if ! grep -q 'CARNet package monit-cn' /etc/init.d/monit; then + # shebang + head -n1 /etc/init.d/monit > /etc/init.d/monit.$$ + # middle part + cp-update monit-cn /etc/init.d/monit.$$ <> /etc/init.d/monit.$$ + mv -f /etc/init.d/monit.$$ /etc/init.d/monit + chmod +x /etc/init.d/monit + fi +fi + # install as inittab service if ! grep -q '/usr/sbin/monit' /etc/inittab; then - if [ -x "/etc/init.d/monit" ]; then - update-rc.d -f monit remove >/dev/null 2>&1 - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d monit stop || true - else - /etc/init.d/monit stop || true - fi - fi echo "CN: Installing monit service in /etc/inittab" rm -f /etc/inittab.$$ cp /etc/inittab /etc/inittab.$$ @@ -75,7 +94,8 @@ EOF fi # reload init, since we have new configuration -echo "CN: Starting monit service, please check /var/log/daemon.log" +echo "CN: (Re)starting monit service, please check /var/log/daemon.log" +pkill -9 -f /usr/sbin/monit || true kill -HUP 1 # dh_installdeb will replace this with shell code automatically diff --git a/debian/postrm b/debian/postrm index 3ec16ad..541b7c1 100755 --- a/debian/postrm +++ b/debian/postrm @@ -34,6 +34,11 @@ esac echo "CN: Removing monit service from /etc/inittab" cp-update -r monit-cn /etc/inittab +# remove us from systemv monit script +echo "CN: Removing monit workaround from /etc/init.d/monit" +cp-update -r monit-cn /etc/init.d/monit +chmod +x /etc/init.d/monit + # kill monit echo "CN: Stopping monit service" pkill -9 -f /usr/sbin/monit || true diff --git a/monit-cn/asterisk.conf b/monit-cn/asterisk.conf new file mode 100644 index 0000000..76fe53e --- /dev/null +++ b/monit-cn/asterisk.conf @@ -0,0 +1,5 @@ +# asterisk monit-cn template + +check process asterisk with pidfile "/var/run/asterisk.pid" + start program = "/etc/init.d/asterisk start" + stop program = "/etc/init.d/asterisk stop" diff --git a/monit-cn/mysqld.conf b/monit-cn/mysqld.conf index 857f4d9..af671e2 100644 --- a/monit-cn/mysqld.conf +++ b/monit-cn/mysqld.conf @@ -3,6 +3,9 @@ check process mysql with pidfile "/var/run/mysqld/mysqld.pid" start program = "/etc/init.d/mysql start" stop program = "/etc/init.d/mysql stop" - if failed host 127.0.0.1 port 3306 protocol mysql + #if failed host 127.0.0.1 port 3306 protocol mysql + # with timeout 10 seconds + # then restart + if failed host 127.0.0.1 port 3306 type tcp with timeout 10 seconds then restart diff --git a/monit-cn/postgrey.conf b/monit-cn/postgrey.conf new file mode 100644 index 0000000..2b939f0 --- /dev/null +++ b/monit-cn/postgrey.conf @@ -0,0 +1,8 @@ +# postgrey monit-cn template + +check process postgrey with pidfile "/var/run/postgrey.pid" + group mail + start program = "/etc/init.d/postgrey start" + stop program = "/etc/init.d/postgrey stop" + if failed host 127.0.0.1 port 60000 type tcp + then restart -- 1.7.10.4