From 4c642e3dc17f98e5560763f019c3eb18e09e5e8c Mon Sep 17 00:00:00 2001 From: Chris Elsworth Date: Tue, 31 Jan 2017 23:30:40 +0000 Subject: Tweak HipChat colours to be a bit more useful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > It would be lovely if cleared messages were green > —- Tom Hill --- lib/mauve/notifiers/hipchat.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mauve/notifiers/hipchat.rb b/lib/mauve/notifiers/hipchat.rb index 7537bc5..b29f450 100644 --- a/lib/mauve/notifiers/hipchat.rb +++ b/lib/mauve/notifiers/hipchat.rb @@ -27,13 +27,13 @@ module Mauve def send_alert(destination, alert, all_alerts, conditions = {}) msg = prepare_message(destination, alert, all_alerts, conditions) - colour = case alert.level - when :urgent - "red" - when :normal - "yellow" + colour = case alert.update_type + when 'cleared' + 'green' + when 'acknowledged' + 'yellow' else - "green" + 'red' end opts = { -- cgit v1.2.1 From 755c3dcbff838cbd833bbd94ddc5e8ad43ea5d06 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:22:46 +0000 Subject: Added CI --- .gitlab-ci.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..001dc74 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,45 @@ +stages: + - test + - package + - publish + +test:jessie: &test + image: $CI_REGISTRY/docker-images/layers:$DISTRO-ruby + stage: test + variables: + DISTRO: jessie + script: + - bundle install -j $(nproc) --path vendor/bundle --binstubs + - bundle exec rake test:unit + +test:stretch: + <<: *test + variables: + DISTRO: stretch + +package:jessie: &package + image: $CI_REGISTRY/docker-images/layers:$DISTRO-deb + stage: package + variables: + DISTRO: jessie + script: + - package + artifacts: + paths: + - pkg/ + +package:stretch: + <<: *package + variables: + DISTRO: stretch + +publish: + stage: publish + tags: + - shell + script: + - publish + dependencies: + - package:jessie + - package:stretch + -- cgit v1.2.1 From 47d3ddcb320675911ec4e55eb5823ebbceeb3687 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:23:50 +0000 Subject: Revert "Strip out debian metadata" This reverts commit 4d9ca84e57dad6746eb0882b91171ccd69298807. --- Makefile | 58 ++- debian/changelog | 721 +++++++++++++++++++++++++++++++++++++ debian/compat | 1 + debian/control | 68 ++++ debian/copyright | 19 + debian/mauvealert-client.install | 3 + debian/mauvealert-client.manpages | 1 + debian/mauvealert-common.install | 6 + debian/mauvealert-server.dirs | 2 + debian/mauvealert-server.docs | 6 + debian/mauvealert-server.examples | 1 + debian/mauvealert-server.init | 225 ++++++++++++ debian/mauvealert-server.install | 38 ++ debian/mauvealert-server.links | 1 + debian/mauvealert-server.logrotate | 10 + debian/mauvealert-server.manpages | 2 + debian/mauvealert-server.postinst | 28 ++ debian/mauvealert-server.postrm | 23 ++ debian/rules | 8 + 19 files changed, 1215 insertions(+), 6 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/mauvealert-client.install create mode 100644 debian/mauvealert-client.manpages create mode 100644 debian/mauvealert-common.install create mode 100644 debian/mauvealert-server.dirs create mode 100644 debian/mauvealert-server.docs create mode 100644 debian/mauvealert-server.examples create mode 100644 debian/mauvealert-server.init create mode 100644 debian/mauvealert-server.install create mode 100644 debian/mauvealert-server.links create mode 100644 debian/mauvealert-server.logrotate create mode 100644 debian/mauvealert-server.manpages create mode 100644 debian/mauvealert-server.postinst create mode 100644 debian/mauvealert-server.postrm create mode 100755 debian/rules diff --git a/Makefile b/Makefile index 0ccfd8c..2254496 100644 --- a/Makefile +++ b/Makefile @@ -15,16 +15,62 @@ man/%.1: bin/% clean: $(RM) -r man + # Theoretically this will clean up the shebang munging done by the openbsd_tarball task below. + if [ -e ./setup.rb ] ; then \ + ruby ./setup.rb distclean ; \ + ruby ./setup.rb config ; \ + ruby ./setup.rb setup ; \ + ruby ./setup.rb clean ; \ + fi $(RM) -r tmp + $(RM) -r OpenBSD + $(RM) setup.rb -# NOP task to keep au happy -release: - true distclean: clean + if [ -e ./setup.rb ] ; then ruby ./setup.rb distclean ; fi + $(RM) setup.rb + $(RM) -r OpenBSD -test: - ruby -Ilib:test:. test/test_mauve.rb +test: setup.rb + ruby ./setup.rb test -.PHONY: all clean test distclean release +setup.rb: /usr/lib/ruby/1.8/setup.rb + ln -sf /usr/lib/ruby/1.8/setup.rb . + +OpenBSD: OpenBSD/sha256.asc + +OpenBSD/sha256: OpenBSD/ruby-mauvealert.tar.gz OpenBSD/ruby-protobuf.tar.gz + # + # rejig sha256sum to openbsd sha256 + # + $(RM) OpenBSD/sha256 + cd OpenBSD && sha256sum * | sed -e 's/\([^ ]\+\) \(.*\)$$/SHA256 (\2) = \1/' > sha256 + +OpenBSD/sha256.asc: OpenBSD/sha256 + # + # Sign it. + # + gpg --clearsign OpenBSD/sha256 + +OpenBSD/ruby-mauvealert.tar.gz: all setup.rb + mkdir -p tmp/ruby-mauvealert + ruby ./setup.rb config ${OPENBSD_SETUP_FLAGS} + ruby ./setup.rb setup + ruby ./setup.rb install --prefix=tmp/ruby-mauvealert + mkdir -p OpenBSD + tar -C tmp/ruby-mauvealert -czvf $@ . + +OpenBSD/ruby-protobuf.tar.gz: + mkdir -p tmp/ruby-protobuf-source + git clone https://github.com/macks/ruby-protobuf.git tmp/ruby-protobuf-source + cd tmp/ruby-protobuf-source && git checkout -b v0.4.5 + ln -sf /usr/lib/ruby/1.8/setup.rb tmp/ruby-protobuf-source/ + cd tmp/ruby-protobuf-source && ruby ./setup.rb config ${OPENBSD_SETUP_FLAGS} + cd tmp/ruby-protobuf-source && ruby ./setup.rb setup + cd tmp/ruby-protobuf-source && ruby ./setup.rb install --prefix=../ruby-protobuf + mkdir -p OpenBSD + tar -C tmp/ruby-protobuf -czvf $@ . + +.PHONY: all clean openbsd_tarball test distclean OpenBSD diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..0627303 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,721 @@ +mauvealert (3.15.15-1) stable; urgency=medium + + * Tidied up iconv usage for ruby1.9+ + + -- Patrick J Cherry Thu, 10 Jul 2014 13:40:27 +0100 + +mauvealert (3.15.14-2) stable; urgency=low + + * Relaxed mauvealert-client ruby dependency. + + -- Patrick J Cherry Thu, 03 Jul 2014 11:43:00 +0100 + +mauvealert (3.15.14-1) stable; urgency=low + + * Web interface now defaults to wall-clock hours. + + -- Patrick J Cherry Wed, 22 May 2013 11:47:52 +0100 + +mauvealert (3.15.13-1) stable; urgency=low + + * Switched off global socket reverse lookups. + + -- Patrick J Cherry Tue, 21 May 2013 14:34:15 +0100 + +mauvealert (3.15.12-1) stable; urgency=low + + * Removed extra database lookup when receiving alert updates. + * Added extra to_a when checking to see if an alert should be suppressed to + force the database lookup at that point. + + -- Patrick J Cherry Tue, 21 May 2013 12:24:13 +0100 + +mauvealert (3.15.11-1) stable; urgency=low + + * Notifications now generate just one history entry to ensure that the + previous changes regarding notification supression work. + + -- Patrick J Cherry Thu, 16 May 2013 14:13:43 +0100 + +mauvealert (3.15.10-1ubuntu1) stable; urgency=low + + * Database is now queried to see if a notification should be suppressed. + * Notification suppression now takes urgency into account, such that more + urgent alerts are not smothered by less urgent ones. + * Templates now include which level the alert is. + + -- Patrick J Cherry Thu, 16 May 2013 11:47:33 +0100 + +mauvealert (3.15.9-1) stable; urgency=low + + * Added Mauve::QuickUpdate library + + -- Patrick J Cherry Thu, 02 May 2013 14:23:34 +0100 + +mauvealert (3.15.8-1) stable; urgency=low + + * Added a further check to make sure the last alert of the same update type + was being updated by reminders. + + -- Patrick J Cherry Wed, 01 May 2013 15:41:10 +0100 + +mauvealert (3.15.7-1) stable; urgency=low + + * Altered alert_group to only set one reminder. + * Allow alert to clear raised_at/cleared_at times if none specified. + + -- Patrick J Cherry Wed, 01 May 2013 10:16:52 +0100 + +mauvealert (3.15.6-2) stable; urgency=low + + * Added generic_http library that had been missed off. + + -- Patrick J Cherry Fri, 25 Jan 2013 13:47:05 +0000 + +mauvealert (3.15.6-1) stable; urgency=low + + * Alert fields are now truncated if they're too long. + + -- Patrick J Cherry Wed, 12 Dec 2012 10:47:28 +0000 + +mauvealert (3.15.5-1) stable; urgency=low + + * Fixed bug whereby alerts cleared by a "replace" flag were not sending + notifications. + * The alert summary is now recorded in the history for an alert. + + -- Patrick J Cherry Wed, 05 Dec 2012 12:34:21 +0000 + +mauvealert (3.15.4-1) stable; urgency=low + + * Fixed typo in AlertGroup. + + -- Patrick J Cherry Tue, 04 Dec 2012 14:34:31 +0000 + +mauvealert (3.15.3-1) stable; urgency=low + + * Further fix-ups to the alert notification suppression code. + + -- Patrick J Cherry Tue, 04 Dec 2012 14:08:47 +0000 + +mauvealert (3.15.2-1) stable; urgency=low + + * Added "eager" loading when looking at event histories. + * Fixed event views to use dates, and to miss queries for days with no + events. + + -- Patrick J Cherry Tue, 04 Dec 2012 11:56:19 +0000 + +mauvealert (3.15.1-1) stable; urgency=low + + * Rationalised alert tables to look the same for both searches and + normal views. + * Events calendar is now faster as fewer queries are made when loading. + + -- Patrick J Cherry Fri, 30 Nov 2012 22:48:43 +0000 + +mauvealert (3.14.2-1) stable; urgency=low + + * Added search views to package + * Alert actions are now controlled by just one form, and two actions. + * Alerts in search results are now de-duped. + * Serch results are only coloured if they're raised. + + -- Patrick J Cherry Fri, 30 Nov 2012 14:55:16 +0000 + +mauvealert (3.14.1-1) stable; urgency=low + + * Web frontend now has a search box. + * Alert counts now reinstated. + + -- Patrick J Cherry Fri, 30 Nov 2012 12:35:44 +0000 + +mauvealert (3.13.2-1) stable; urgency=low + + * Raised time now set to unacknowledgment time when alerts become + unacknowledged + * Tidied up history entries + * Changed UNACKNOWLEDGED to RE-RAISED when alerts are no longer ack'd + * Added suppression information to views + + -- Patrick J Cherry Thu, 29 Nov 2012 21:05:51 +0000 + +mauvealert (3.13.1-1) stable; urgency=low + + * Rewrote decision code for notifying on save for an alert. + + -- Patrick J Cherry Thu, 29 Nov 2012 16:17:11 +0000 + +mauvealert (3.12.1-1) stable; urgency=low + + * Added optional notification suppression for alerts. + + -- Patrick J Cherry Thu, 29 Nov 2012 10:35:04 +0000 + +mauvealert (3.11.8-1) stable; urgency=low + + * Re-wrote alert saving logic to use database transactions. + + -- Patrick J Cherry Tue, 27 Nov 2012 16:16:09 +0000 + +mauvealert (3.11.7-1) stable; urgency=low + + * Models are now more picky when setting created_at/updated_at times. + + -- Patrick J Cherry Tue, 27 Nov 2012 11:51:55 +0000 + +mauvealert (3.11.6-2) stable; urgency=low + + * Fixed missing library file. + + -- Patrick J Cherry Tue, 27 Nov 2012 10:16:35 +0000 + +mauvealert (3.11.6-1) stable; urgency=low + + * Added dm-validations monkey-patch to automatically save validation + failures, when no failures are given. + * Reverted change to AlertChanged. + + -- Patrick J Cherry Tue, 27 Nov 2012 09:55:44 +0000 + +mauvealert (3.11.5-1) stable; urgency=low + + * Now uses ruby-ipaddress instead of IPAddr. + * Now logs when AlertChanged fails, and bypassess validation when needed. + + -- Patrick J Cherry Mon, 26 Nov 2012 17:06:39 +0000 + +mauvealert (3.11.4-1) stable; urgency=low + + * AlertGroup is no longer looked for on raise/clear/ack. It is looked up on + notification. + * Update web_interface to use public_folder instead of just public + * Tidied notifier a little. Alert#cached_alert_group is reset before + notification. + + -- Patrick J Cherry Fri, 23 Nov 2012 15:43:11 +0000 + +mauvealert (3.11.3-3) stable; urgency=low + + * dm-aggregates now included. + + -- Patrick J Cherry Fri, 23 Nov 2012 13:05:26 +0000 + +mauvealert (3.11.3-2) stable; urgency=low + + * Updated dependencies to take new-style library names + + -- Patrick J Cherry Fri, 23 Nov 2012 12:03:49 +0000 + +mauvealert (3.11.3) stable; urgency=low + + * minimal_dns_lookups configuration item added, preventing extra DNS lookups + when matching hosts to source lists. + * When the cached alert group is saved (in Notifier#notify) the callbacks + which trigger notifications are now skipped. + * Tidied up postgres test failure. + + -- Patrick J Cherry Fri, 23 Nov 2012 10:49:21 +0000 + +mauvealert (3.11.2) stable; urgency=low + + * Fixed typo in WebInterface. + * Make sure alerts only get sent on save if their status has changed. + + -- Patrick J Cherry Wed, 21 Nov 2012 16:38:00 +0000 + +mauvealert (3.11.1) stable; urgency=low + + * Added a sleep to the server main loop + * The alert gets saved after notification to make sure that the + cached_alert_group gets stored. + * xmmp errors now crash mauve completely. (deliberately). + + -- Patrick J Cherry Wed, 21 Nov 2012 14:32:20 +0000 + +mauvealert (3.11.0) stable; urgency=low + + * Removed needless counting of alerts in the web interface + * Made alert queries more accurate + * Removed duplicate code in Alert#in_source_list + * Cut down on the number of DNS queries in SourceList#includes? + + -- Patrick J Cherry Wed, 21 Nov 2012 14:20:42 +0000 + +mauvealert (3.10.0) stable; urgency=low + + * Added URLs which can be polled for source lists + * Removed freeze/thaw functionality from the threads which hasn't been used + for a while. + * Threads are now checked to make sure they're running, and not stuck. + + -- Patrick J Cherry Thu, 05 Jul 2012 14:00:55 +0100 + +mauvealert (3.9.4) stable; urgency=low + + * Clear cleared_at time if raised_at time is set on alert reception. + + -- Patrick J Cherry Mon, 02 Jul 2012 11:33:35 +0100 + +mauvealert (3.9.3) stable; urgency=low + + * no_one_in is now only called once per DuringRunner instance per + people_list to try and reduce hammering on the calendar. + * Fixed notify_when_on_holiday/off_sick to actually work. + + -- Patrick J Cherry Fri, 08 Jun 2012 10:32:23 +0100 + +mauvealert (3.9.2) stable; urgency=low + + * Removed destroy XMPP command -- replaced with clear. + + -- Patrick J Cherry Wed, 09 May 2012 17:05:43 +0100 + +mauvealert (3.9.1) stable; urgency=low + + * Web interface now uses an ajax call to work out ack times, falling back to + javascript if that takes too long. + * Default working hours are now 9.30 - 5.30 as per SLA. + * Fixed time tests + standardised dead zone + daylight hours. + * Fixed up PeopleList#resolve_notifications to check for recursion, and only + return notify clauses that refer to people. + * Changed Person#resolve_notification to match the signature for the + people_list version. + * Updated notifier only to try to connect to objects that respond to xmpp. + + -- Patrick J Cherry Tue, 08 May 2012 12:05:56 +0100 + +mauvealert (3.9.0) stable; urgency=low + + * Notify anyone who has contributed to an alert's history since its last + raise, either by acknowledging, or by being notified about it. + * Username is now recorded in the History wherever possible. + * Update Time.bank_holiday? etc. to work correctly. + * Mauve::Configuration#do_parse_time now a class method, and used elsewhere + to standardise ranges in the configuration file. + * Updated notification tests to test bank_holiday changes etc. + * Person and people lists have now become interchangeable, with + notifications only recording the username, rather than the + Person/PeopleList. This means that notifications in alert groups can use + default #during clauses and #every values from people lists and persons. + * Notify clauses can now take an array of persons/people_lists, and + people_lists can refer to other people lists. + * PeopleList names are now in the same namespace as usernames. + + -- Patrick J Cherry Fri, 04 May 2012 16:52:39 +0100 + +mauvealert (3.8.5) stable; urgency=low + + * Added configuration options for daytime_hours, dead_zone, and + working_hours. + * Updated views to be neater with respect to notice/errors and in the case + when no alerts are found in a table. + * Set default hostname to Socket.gethostname, and default base_url now + includes the port, if it is not port 80 + * Added ruby locale dependency for server. + * Symlink jquery if possible in server postinst. + * Updated history partial to be better. + * Updated sender to try and get things into UTF8 where poss. + * Fixed warn on nil method in person. + + -- Patrick J Cherry Wed, 02 May 2012 15:24:52 +0100 + +mauvealert (3.8.4) stable; urgency=low + + * Fixed notification when on holiday/off sick + * Strings are now stripped of any illegal/non-UTF8 characters + + -- Patrick J Cherry Mon, 30 Apr 2012 12:53:33 +0100 + +mauvealert (3.8.3) stable; urgency=low + + * Reverted bad changes to mauveserver + example.conf + * Added default options for a person + * Added calendar check for a people_list + * Added a time at which to check the people in a people_list + + -- Patrick J Cherry Fri, 27 Apr 2012 11:56:52 +0100 + +mauvealert (3.8.2) stable; urgency=low + + * Reverted a couple of duff changes. + + -- Patrick J Cherry Fri, 27 Apr 2012 11:00:21 +0100 + +mauvealert (3.8.1) stable; urgency=low + + * Calendar now honours http timeout + ssl verify settings. + * Added no_one_in test for DuringRunner + + -- Patrick J Cherry Fri, 27 Apr 2012 09:32:02 +0100 + +mauvealert (3.8.0) stable; urgency=low + + * HTML sanitizing only takes place if the text looks like HTML. + * Tests improved to couple processor and notifier buffers. + * Added authentication tests + * Removed remote auth tests in from the web interface tests. + * If no bytemark_auth_url is set, then no remote auth takes place. + * SSL peer cert validation now takes place by default. + * People/PeopleLists can now specify individualy notification times/frequencies + * Notification now uses #during/#every from the Person/PeopleList if nothing was specified + * Max acknowledgement time is now specified in the config + * Calendar interface improved. + * holiday_url no longer used -- replaced by notify_when_on_holiday! + * added notify_when_off_sick! + * Added ability for the calendar to be queried for a list of bank holdays. + * Added ability for Time to be given a list of bank holidays to check + against. + * PeopleLists can now be a Proc, allowing downloading of lists. + * Testing is much improved. + + -- Patrick J Cherry Wed, 25 Apr 2012 17:16:56 +0100 + +mauvealert (3.7.8) stable; urgency=low + + * Reduced the liklihood of race conditions during evaluation of during {} + clauses. + * Added cache to DuringRunner to reduce the number of times now? is + evaluated. + * Added a debug! option to notification_method clauses for easier, erm, + debugging. + * Alert#notify and AlertChanged#notify now make use of the notification + buffer make the disconnection betweeen the processing loop and + notifications happen sooner. + * Manpage typo sorted out. + * - + + -- Patrick J Cherry Fri, 27 Apr 2012 09:10:37 +0100 + +mauvealert (3.7.7) stable; urgency=low + + * Javascript refreshes now happen every two minutes. + * Alert now tries to find just one matching AlertGroup, not all. + + -- Patrick J Cherry Fri, 23 Mar 2012 15:02:53 +0000 + +mauvealert (3.7.6) stable; urgency=low + + * Tweaked alert display to show the alert_group properly. + * Bumped Mauve::Version correctly. + + -- Patrick J Cherry Thu, 22 Mar 2012 17:55:51 +0000 + +mauvealert (3.7.5) stable; urgency=low + + * Added tests for web interface. + * Tidied up HTTP auth codes when auth fails. + * Further tweaks to alert_group caching, and source_list searches. + + -- Patrick J Cherry Thu, 22 Mar 2012 17:44:58 +0000 + +mauvealert (3.7.4) stable; urgency=low + + * Possible improvements in alert group caching, in an attempt to fix + slowness in the interface. + + -- Patrick J Cherry Thu, 22 Mar 2012 10:06:07 +0000 + +mauvealert (3.7.3) stable; urgency=low + + * Added destroy command to XMPP interface. + + -- Patrick J Cherry Tue, 28 Feb 2012 14:35:17 +0000 + +mauvealert (3.7.2) stable; urgency=low + + * Fixed Hash/Array confusions when merging conditions for notification. + + -- Patrick J Cherry Thu, 02 Feb 2012 10:59:28 +0000 + +mauvealert (3.7.1) stable; urgency=low + + * Fixed debian packaging to install everything. + + -- Patrick J Cherry Mon, 30 Jan 2012 17:03:48 +0000 + +mauvealert (3.7.0) stable; urgency=low + + * Bundled timer in with processor. What could go wrong..? + * Updated example.conf to work + * Added possibility of using postgres databases. + + -- Patrick J Cherry Mon, 30 Jan 2012 12:31:06 +0000 + +mauvealert (3.6.3) stable; urgency=low + + * Logs received at time in Processor + * Added lsb-base dependency + * Added test-task to init script + * Added include, include_file, and include_directory directives to + configuration. + + -- Patrick J Cherry Fri, 06 Jan 2012 14:41:45 +0000 + +mauvealert (3.6.2) stable; urgency=low + + * Tinkered with dependencies + + -- Patrick J Cherry Mon, 07 Nov 2011 10:09:54 +0000 + +mauvealert (3.6.1) stable; urgency=low + + * Fixed up alert ack parsing a bit. + + -- Patrick J Cherry Mon, 07 Nov 2011 09:38:05 +0000 + +mauvealert (3.6.0) stable; urgency=low + + * Changed ack command to split on spaces or commas or both + * Fixed initscripts to, erm, work when VERBOSE is not set + * Robustificated XMPP some more + * Moved all timestamps into epoch time from regular timestamps + + -- Patrick J Cherry Fri, 04 Nov 2011 08:33:13 +0000 + +mauvealert (3.5.10) stable; urgency=low + + * Fixed up Pop3Client class to work. + + -- Patrick J Cherry Tue, 04 Oct 2011 15:29:22 +0100 + +mauvealert (3.5.9) stable; urgency=low + + * Improve documentation in code + * Fix XMPP crash problem properly + * Fix XMPP acknowledge syntax for minutes, seconds, etc. + * Update template to remove colon between the subject and summary. + + -- Patrick J Cherry Fri, 16 Sep 2011 13:20:51 +0100 + +mauvealert (3.5.8) stable; urgency=low + + * Added rescue clause to XMPP connect + + -- Patrick J Cherry Tue, 13 Sep 2011 07:56:38 +0100 + +mauvealert (3.5.7) stable; urgency=low + + * Reminders are now unconditionally cleared when an alert is cleared. + + -- Patrick J Cherry Mon, 12 Sep 2011 11:18:09 +0100 + +mauvealert (3.5.6) stable; urgency=low + + * XMPP interface now saves note. + + -- Patrick J Cherry Tue, 06 Sep 2011 15:56:01 +0100 + +mauvealert (3.5.5) stable; urgency=low + + * Further updates to the suppression code. Should be much better now. + * XMPP interface fixed. + + -- Patrick J Cherry Tue, 06 Sep 2011 15:30:11 +0100 + +mauvealert (3.5.4) stable; urgency=low + + * Fixed up alert suppression to work better + * Also allow multiple suppression clauses in config + * Test for dual alerts when an alert unacknowledges. + + -- Patrick J Cherry Tue, 06 Sep 2011 11:06:09 +0100 + +mauvealert (3.5.3) stable; urgency=low + + * Fixed do_get timeout + * Added small cache for fetching external URIs. + + -- Patrick J Cherry Wed, 31 Aug 2011 14:03:45 +0100 + +mauvealert (3.5.2) stable; urgency=low + + * Added holiday checks + * Suppression now a bit less jumpy. + + -- Patrick J Cherry Wed, 31 Aug 2011 13:07:50 +0100 + +mauvealert (3.5.1) stable; urgency=low + + * Fixed XMPP interface to allow ack's from groupchat. + * Fixed XMPP interface to allow private chats to work. + + -- Patrick J Cherry Wed, 24 Aug 2011 16:55:30 +0100 + +mauvealert (3.5.0) stable; urgency=low + + * Added XMPP interface + + -- Patrick J Cherry Wed, 24 Aug 2011 12:24:55 +0100 + +mauvealert (3.4.4) stable; urgency=low + + * Added events calendar + + -- Patrick J Cherry Tue, 23 Aug 2011 18:24:52 +0100 + +mauvealert (3.4.3) stable; urgency=low + + * Fixed notification race-conditions. + * Reminders now get sent at the start of the next during period. + + -- Patrick J Cherry Mon, 22 Aug 2011 11:58:28 +0100 + +mauvealert (3.4.2) stable; urgency=low + + * Improved polling interval timing. + + -- Patrick J Cherry Fri, 19 Aug 2011 16:56:33 +0100 + +mauvealert (3.4.1) stable; urgency=low + + * Fixed note in alert acknowledgement box + * HTML now sanitized on save for Alert and History types + * Default thread interval now 0s for UDP server and Timer, 5s for everything + else + * Moar tests + + -- Patrick J Cherry Fri, 19 Aug 2011 16:24:56 +0100 + +mauvealert (3.4.0) stable; urgency=low + + * More thread monitoring + * Altered alert path for reminders + * Lengthened cookie lifetime + * Added an initial logger + * Can now have one history with multiple alerts + * Changed DateTime to Time everywhere + * Moar tests + + -- Patrick J Cherry Wed, 17 Aug 2011 14:26:18 +0100 + +mauvealert (3.3.2) stable; urgency=low + + * More pop3 tweaks + + -- Patrick J Cherry Thu, 04 Aug 2011 17:18:13 +0100 + +mauvealert (3.3.1) stable; urgency=low + + * Fixed bug in Pop3 server + + -- Patrick J Cherry Thu, 04 Aug 2011 15:18:27 +0100 + +mauvealert (3.3.0) stable; urgency=low + + * Added pop3 server + * Rejigged authentication + * Web interface improvements + + -- Patrick J Cherry Thu, 04 Aug 2011 14:26:24 +0100 + +mauvealert (3.2.1) stable; urgency=low + + * Fixed up alert_group matching. + + -- Patrick J Cherry Fri, 22 Jul 2011 16:28:52 +0100 + +mauvealert (3.2.0) stable; urgency=low + + * Re-organisation of config + * Added lots of tests. + + -- Patrick J Cherry Fri, 22 Jul 2011 13:30:23 +0100 + +mauvealert (3.1.6) stable; urgency=low + + * Added new heartbeat to remote mauve + * Added alert URL to messages. + + -- Patrick J Cherry Wed, 20 Jul 2011 16:15:07 +0100 + +mauvealert (3.1.5) stable; urgency=low + + * mauvesend can now specify an absolute time + + -- Patrick J Cherry Wed, 20 Jul 2011 10:54:17 +0100 + +mauvealert (3.1.4) stable; urgency=low + + * Fixed up recording of update_type for alerts + * Tidied up threading. + + -- Patrick J Cherry Tue, 19 Jul 2011 22:44:30 +0100 + +mauvealert (3.1.3) stable; urgency=low + + * Tidied up initscript + + -- Patrick J Cherry Tue, 19 Jul 2011 17:59:01 +0100 + +mauvealert (3.1.2) stable; urgency=low + + * Fixed up some gruesome spelling errors. + + -- Patrick J Cherry Tue, 19 Jul 2011 16:42:19 +0100 + +mauvealert (3.1.1) stable; urgency=low + + * Fixed mauveserver config file searching + * Updated dependencies for lenny (ugh) + + -- Patrick J Cherry Tue, 19 Jul 2011 15:48:53 +0100 + +mauvealert (3.1.0) stable; urgency=low + + * New version. + + -- Patrick J Cherry Fri, 15 Jul 2011 14:03:15 +0100 + +mauvealert (3.0.6) stable; urgency=low + + * Reminders to peple lists now work. + + -- Patrick J Cherry Sun, 19 Jun 2011 21:52:16 +0100 + +mauvealert (3.0.5) stable; urgency=low + + * Moar fiXXord. + + -- Patrick J Cherry Fri, 17 Jun 2011 18:08:21 +0100 + +mauvealert (3.0.4) stable; urgency=low + + * New release. + + -- Patrick J Cherry Fri, 17 Jun 2011 08:57:55 +0100 + +mauvealert (3.0.3) stable; urgency=low + + * Added get_all back to front-end + * Fixed up logging for more classes + * Catch empty notification lists + * Added console to server package + * Fixed document_root location + + -- Patrick J Cherry Tue, 19 Apr 2011 11:31:10 +0100 + +mauvealert (3.0.2) stable; urgency=low + + * Now checks for transmission time set to zero. + + -- Patrick J Cherry Tue, 19 Apr 2011 10:27:13 +0100 + +mauvealert (3.0.1) stable; urgency=low + + * Fixed up logging for the web interface + * Added better catch for validation errors + + -- Patrick J Cherry Tue, 19 Apr 2011 10:18:44 +0100 + +mauvealert (3.0.0) stable; urgency=low + + * New version. + + -- Patrick J Cherry Wed, 13 Apr 2011 17:02:22 +0100 + +mauvealert (0.1-1) stable; urgency=low + + * First release. + + -- Patrick J Cherry Wed, 28 Oct 2009 10:34:17 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1fdc4f5 --- /dev/null +++ b/debian/control @@ -0,0 +1,68 @@ +Source: mauvealert +Maintainer: Matthew Bloch +Uploaders: Patrick J Cherry +Section: ruby +Priority: optional +Build-Depends: ruby | ruby-interpreter, debhelper, cdbs, rdoc, txt2man, cdbs, libsetup-ruby1.8 | ruby-setup +Standards-Version: 3.9.1 + +Package: mauvealert-client +Architecture: all +Depends: ruby | ruby-interpreter, + mauvealert-common (>= 3.8.0), + ${misc:Depends} +Recommends: liblocale-ruby1.8 | ruby-locale +Description: Mauve network alert system -- client + Mauve is a network alert system for system and network administrators. You + can use it to quickly set up ad-hoc monitoring for a variety of services, and + to confidently replace all scripts that might otherwise send floods of emails + or text messages. + . + This is the client package. + +Package: mauvealert-server +Architecture: all +Pre-Depends: libjs-jquery +Depends: mauvealert-common (>= 3.8.0), + adduser, + ruby-dm-core (>= 1.2.0) | libdm-core-ruby1.8 (>= 1.2.0), + ruby-dm-migrations (>= 1.2.0) | libdm-migrations-ruby1.8 (>= 1.2.0), + ruby-dm-sqlite-adapter (>= 1.2.0) | libdm-sqlite-adapter-ruby1.8 (>= 1.2.0), + ruby-dm-types (>= 1.2.0) | libdm-types-ruby1.8 (>= 1.2.0), + ruby-dm-aggregates (>= 1.2.0) | libdm-aggregates-ruby1.8 (>= 1.2.0), + ruby-dm-validations (>= 1.2.0) | libdm-validations-ruby1.8 (>= 1.2.0), + ruby-dm-transactions (>= 1.2.0) | libdm-transactions-ruby1.8 (>= 1.2.0), + ruby-haml (>= 3.0.15) | libhaml-ruby1.8 (>= 3.0.15) | haml (>= 3.0.15), + ruby-sanitize (>= 2.0.3) | libsanitize-ruby1.8 (>= 2.0.3), + ruby-sinatra (>= 1.0) | libsinatra-ruby1.8 (>= 1.0), + ruby-ipaddress | libipaddresss-ruby1.8, + ruby-log4r | liblog4r-ruby1.8, + ruby-redcloth | libredcloth-ruby1.8, + ruby-rmail | librmail-ruby1.8, + ruby-thin | thin1.8 | thin, + ruby-xmpp4r | libxmpp4r-ruby1.8, + lsb-base (>= 3.2-14), + ruby1.8 (>= 1.8.7), + ${misc:Depends} +Suggests: mauvealert-client +Recommends: ruby-locale | liblocale-ruby1.8 +Description: Mauve network alert system -- server + Mauve is a network alert system for system and network administrators. You can + use it to quickly set up ad-hoc monitoring for a variety of services, and to + confidently replace all scripts that might otherwise send floods of emails or + text messages. + . + This is the server package. + +Package: mauvealert-common +Architecture: all +Depends: ruby | ruby-interpreter, ruby-protobuf, ${misc:Depends} +Suggests: mauvealert-client +Description: Mauve network alert system -- common libraries + Mauve is a network alert system for system and network administrators. You can + use it to quickly set up ad-hoc monitoring for a variety of services, and to + confidently replace all scripts that might otherwise send floods of emails or + text messages. + . + This is the package of libraries in common with both the client and server. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e0fe391 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,19 @@ +This is Mauve Alert, Bytemark's networked alert system. + +Copyright © 2009 Bytemark Computer Consulting Ltd + +Licence: + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License can be found in ‘/usr/share/common-licenses/GPL’ or in the dpkg +source as the file ‘COPYING’ diff --git a/debian/mauvealert-client.install b/debian/mauvealert-client.install new file mode 100644 index 0000000..5cdaca6 --- /dev/null +++ b/debian/mauvealert-client.install @@ -0,0 +1,3 @@ +bin/mauvesend usr/bin/ +lib/mauve/sender.rb usr/lib/ruby/vendor_ruby/mauve/ +lib/mauve/quick_update.rb usr/lib/ruby/vendor_ruby/mauve/ diff --git a/debian/mauvealert-client.manpages b/debian/mauvealert-client.manpages new file mode 100644 index 0000000..d8c2d70 --- /dev/null +++ b/debian/mauvealert-client.manpages @@ -0,0 +1 @@ +man/mauvesend.1 diff --git a/debian/mauvealert-common.install b/debian/mauvealert-common.install new file mode 100644 index 0000000..b132d51 --- /dev/null +++ b/debian/mauvealert-common.install @@ -0,0 +1,6 @@ +mauve.proto usr/lib/mauvealert/ +lib/mauve/proto.rb usr/lib/ruby/vendor_ruby/mauve/ +lib/mauve/mauve_time.rb usr/lib/ruby/vendor_ruby/mauve/ +lib/mauve/version.rb usr/lib/ruby/vendor_ruby/mauve/ +lib/mauve/mauve_resolv.rb usr/lib/ruby/vendor_ruby/mauve/ + diff --git a/debian/mauvealert-server.dirs b/debian/mauvealert-server.dirs new file mode 100644 index 0000000..ae8ddd8 --- /dev/null +++ b/debian/mauvealert-server.dirs @@ -0,0 +1,2 @@ +var/lib/mauvealert +var/log/mauvealert diff --git a/debian/mauvealert-server.docs b/debian/mauvealert-server.docs new file mode 100644 index 0000000..20c256d --- /dev/null +++ b/debian/mauvealert-server.docs @@ -0,0 +1,6 @@ +bytemark_example_alerts.sh +bytemark_policy.txt +CHANGELOG +README +TODO +TODO-PJC diff --git a/debian/mauvealert-server.examples b/debian/mauvealert-server.examples new file mode 100644 index 0000000..ae5a993 --- /dev/null +++ b/debian/mauvealert-server.examples @@ -0,0 +1 @@ +example.conf diff --git a/debian/mauvealert-server.init b/debian/mauvealert-server.init new file mode 100644 index 0000000..71d287d --- /dev/null +++ b/debian/mauvealert-server.init @@ -0,0 +1,225 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mauvealert-server +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Mauve Alert Server +# Description: Mauve Alert Server +### END INIT INFO + +# Author: Patrick J Cherry +# + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Mauve Alert Server" +NAME=mauveserver +DAEMON=/usr/sbin/$NAME +DAEMON_ARGS="/etc/mauvealert/$NAME.conf" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME +RUNASUSER=mauvealert + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + do_test || return 2 + + start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --chuid $RUNASUSER --background --startas $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. + count=0 + + while [ $((count = count + 1)) -le 5 ] ; do + sleep 1 + # This is just a test to see if the daemon is running yet. + start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \ + || return 0 + done + + return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --user $RUNASUSER + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --user $RUNASUSER + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --user $RUNASUSER + return 0 +} + +# +# Function that sends a SIGUSR1 to reopen logfiles +# +do_reopenlogs() { + start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --user $RUNASUSER + return 0 +} + + +# +# Test the config file before execution +# +do_test() { + # + # Make sure we're root + # + [ "$USER" = "root" ] || return 1 + + # + # OK test. + # + su $RUNASUSER -s /bin/bash -c "$DAEMON -t $DAEMON_ARGS" 1>/dev/null 2>&1 || return 1 + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 || exit 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 || exit 1 ;; + esac + ;; + + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 || exit 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 || exit 1 ;; + esac + ;; + + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + reload|force-reload) + log_daemon_msg "Reloading $DESC" "$NAME" + do_reload + log_end_msg $? + ;; + + # + # This is for use by logrotate, as the post-rotate method. + # + reopen-logs) + log_daemon_msg "Re-opening logs for $DESC" "$NAME" + do_reopenlogs + log_end_msg $? + ;; + + # + # This is to test the configuration + # + test|config-test) + log_daemon_msg "Testing configuration for $DESC" "$NAME" + do_test + log_end_msg $? + ;; + + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + restart) + log_daemon_msg "Restarting $DESC" "$NAME" + + do_test + if [ "$?" != "0" ] ; then + log_end_msg 1 # test failed + fi + + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|test}" >&2 + exit 3 + ;; +esac + diff --git a/debian/mauvealert-server.install b/debian/mauvealert-server.install new file mode 100644 index 0000000..ca7eb5f --- /dev/null +++ b/debian/mauvealert-server.install @@ -0,0 +1,38 @@ +bin/mauveserver usr/sbin/ +bin/mauveconsole usr/sbin/ +lib/dm-sqlite-adapter-with-mutex.rb usr/lib/ruby/1.8/ +lib/dm-validations-with-empty-errors-hack.rb usr/lib/ruby/1.8/ +lib/mauve/alert.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/alert_changed.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/alert_group.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/authentication.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/calendar_interface.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/configuration.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/configuration_builder.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/configuration_builders.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/configuration_builders usr/lib/ruby/1.8/mauve/ +lib/mauve/datamapper.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/generic_http_api_client.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/heartbeat.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/history.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/http_server.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/mauve_thread.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/notification.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/notifier.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/notifiers usr/lib/ruby/1.8/mauve/ +lib/mauve/notifiers.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/people_list.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/person.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/pop3_server.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/processor.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/server.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/source_list.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/udp_server.rb usr/lib/ruby/1.8/mauve/ +lib/mauve/web_interface.rb usr/lib/ruby/1.8/mauve/ +lib/object_builder.rb usr/lib/ruby/1.8/ +lib/rack-flash.rb usr/lib/ruby/1.8/ +lib/sinatra-partials.rb usr/lib/ruby/1.8/ +static usr/share/mauvealert +views usr/share/mauvealert +etc/mauveserver.conf etc/mauvealert/ + diff --git a/debian/mauvealert-server.links b/debian/mauvealert-server.links new file mode 100644 index 0000000..bc1cdbe --- /dev/null +++ b/debian/mauvealert-server.links @@ -0,0 +1 @@ +usr/share/javascript/jquery usr/share/mauvealert/static/javascript/jquery diff --git a/debian/mauvealert-server.logrotate b/debian/mauvealert-server.logrotate new file mode 100644 index 0000000..9d15453 --- /dev/null +++ b/debian/mauvealert-server.logrotate @@ -0,0 +1,10 @@ +/var/log/mauvealert/mauvealert.log { + rotate 7 + daily + compress + delaycompress + postrotate + /usr/sbin/invoke-rc.d mauvealert-server reopen-logs >/dev/null + endscript +} + diff --git a/debian/mauvealert-server.manpages b/debian/mauvealert-server.manpages new file mode 100644 index 0000000..5d0c618 --- /dev/null +++ b/debian/mauvealert-server.manpages @@ -0,0 +1,2 @@ +man/mauveserver.1 +man/mauveconsole.1 diff --git a/debian/mauvealert-server.postinst b/debian/mauvealert-server.postinst new file mode 100644 index 0000000..967aa8d --- /dev/null +++ b/debian/mauvealert-server.postinst @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +## +# Add a mauve user +## +RUNASUSER=mauvealert + +adduser --system --no-create-home --home /nonexistent $RUNASUSER > /dev/null + +## +# Add default directories +## +for i in log lib ; do + mkdir -p /var/$i/mauvealert + chown -R $RUNASUSER:nogroup /var/$i/mauvealert +done + +# +# Symlink jquery libraries in. +# +if [ -e /usr/share/javascript/jquery -a ! -e /usr/share/mauvealert/static/javascript/jquery ] ; then + ln -s /usr/share/javascript/jquery /usr/share/mauvealert/static/javascript/ +fi + + +#DEBHELPER# diff --git a/debian/mauvealert-server.postrm b/debian/mauvealert-server.postrm new file mode 100644 index 0000000..24fd158 --- /dev/null +++ b/debian/mauvealert-server.postrm @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +## +# Add a mauve user +## +RUNASUSER=mauvealert + +if [ "$1" = "purge" ] ; then + ## + # Remove the system user + ## + deluser --system $RUNASUSER > /dev/null + + ## + # remove default directories + ## + rm -rf /var/log/mauvealert/ + rm -rf /var/lib/mauvealert/ +fi + +#DEBHELPER# diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..99a63c4 --- /dev/null +++ b/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +# +# Use CDBS, so we can build for etch (ugh) +# + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/makefile.mk + -- cgit v1.2.1 From ae24729c935c898806dbcb8c784bd079e1ca6f26 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:25:59 +0000 Subject: Added xml2-dev to test environment --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 001dc74..e7fab4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ test:jessie: &test variables: DISTRO: jessie script: + - apt-get install libxml2-dev - bundle install -j $(nproc) --path vendor/bundle --binstubs - bundle exec rake test:unit -- cgit v1.2.1 From 64a648746c21e4de31c58adff48137ce1a9f7cbf Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:28:20 +0000 Subject: Added xslt library for testing --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7fab4e..20e64d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ test:jessie: &test variables: DISTRO: jessie script: - - apt-get install libxml2-dev + - apt-get install libxml2-dev libxslt1-dev - bundle install -j $(nproc) --path vendor/bundle --binstubs - bundle exec rake test:unit -- cgit v1.2.1 From 36cdba8c351a20717593d6b2cc08685e425c8db0 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:31:43 +0000 Subject: Added libpq-dev --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20e64d1..0fa31d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ test:jessie: &test variables: DISTRO: jessie script: - - apt-get install libxml2-dev libxslt1-dev + - apt-get install libxml2-dev libxslt1-dev libpq-dev - bundle install -j $(nproc) --path vendor/bundle --binstubs - bundle exec rake test:unit -- cgit v1.2.1 From 3388a456a3b954142f5a6dbe684da07113a0d12c Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:37:17 +0000 Subject: Added postgres-dev, libsqlite3-dev --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0fa31d9..bd0e01c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ test:jessie: &test variables: DISTRO: jessie script: - - apt-get install libxml2-dev libxslt1-dev libpq-dev + - apt-get install libxml2-dev libxslt1-dev libpq-dev postgresql-server-dev-9.4 libsqlite3-dev - bundle install -j $(nproc) --path vendor/bundle --binstubs - bundle exec rake test:unit -- cgit v1.2.1 From 37594f4b48a474d33496109f53455bb0adf5ffce Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:37:41 +0000 Subject: Added rake --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd0e01c..347f1c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ test:jessie: &test variables: DISTRO: jessie script: - - apt-get install libxml2-dev libxslt1-dev libpq-dev postgresql-server-dev-9.4 libsqlite3-dev + - apt-get install libxml2-dev libxslt1-dev libpq-dev postgresql-server-dev-9.4 libsqlite3-dev rake - bundle install -j $(nproc) --path vendor/bundle --binstubs - bundle exec rake test:unit -- cgit v1.2.1 From cce9b3743fa1128ffb72b7d2c5f5aa94a52993e9 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 13:39:43 +0000 Subject: updated json gem to one that compiles --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 87cffd8..8c0ed3c 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem "log4r", "=1.0.6" gem "ipaddress", "=0.8.0" gem "webmock", "=1.7.6" gem "ruby_protobuf", "=0.4.11" -gem "json", "=1.5.4" +gem "json", "=1.8.1" gem "datamapper", "=1.2.0" gem "dm-aggregates", "=1.2.0" gem "dm-do-adapter", "=1.2.0" -- cgit v1.2.1 From c1ca338fdb32b05fd047730be9ca6569d22c6806 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 20 Mar 2017 14:08:34 +0000 Subject: Updated gems to (roughly) jessie versions; removed XMPP support. Also changed the postgres tests to "skip" if no postgres db is available. --- Gemfile | 57 +- Gemfile.lock | 145 ++-- lib/mauve/configuration_builders/person.rb | 5 +- lib/mauve/notifier.rb | 46 +- lib/mauve/notifiers.rb | 1 - .../notifiers/templates/email_subject.txt.erb | 2 +- lib/mauve/notifiers/templates/hipchat.txt.erb | 2 +- lib/mauve/notifiers/templates/sms.txt.erb | 23 +- lib/mauve/notifiers/templates/xmpp.html.erb | 23 - lib/mauve/notifiers/templates/xmpp.txt.erb | 22 - lib/mauve/notifiers/xmpp.rb | 837 --------------------- lib/mauve/people_list.rb | 5 - lib/mauve/person.rb | 14 +- test/mauve_test_helper.rb | 2 +- test/tc_mauve_configuration_builders_person.rb | 3 - test/tc_mauve_database_peculiarities.rb | 2 +- 16 files changed, 134 insertions(+), 1055 deletions(-) mode change 120000 => 100644 lib/mauve/notifiers/templates/sms.txt.erb delete mode 100644 lib/mauve/notifiers/templates/xmpp.html.erb delete mode 100644 lib/mauve/notifiers/templates/xmpp.txt.erb delete mode 100644 lib/mauve/notifiers/xmpp.rb diff --git a/Gemfile b/Gemfile index 8c0ed3c..0bd6198 100644 --- a/Gemfile +++ b/Gemfile @@ -1,36 +1,35 @@ source "https://rubygems.org" -gem "bcrypt-ruby", "=3.0.1" -gem "timecop", "=0.3.5" -gem "log4r", "=1.0.6" -gem "ipaddress", "=0.8.0" -gem "webmock", "=1.7.6" -gem "ruby_protobuf", "=0.4.11" -gem "json", "=1.8.1" -gem "datamapper", "=1.2.0" -gem "dm-aggregates", "=1.2.0" -gem "dm-do-adapter", "=1.2.0" -gem "dm-migrations", "=1.2.0" -gem "dm-postgres-adapter", "=1.2.0" -gem "dm-sqlite-adapter", "=1.2.0" -gem "dm-transactions", "=1.2.0" -gem "dm-types", "=1.2.0" -gem "dm-validations", "=1.2.0" -gem "sanitize", "=2.0.3" -gem "rmail", "=1.1.0" -gem "xmpp4r", "=0.5.6" -gem "thin", "=1.6.3" -gem "haml", "=3.0.15" -gem "RedCloth" -gem "rack" -gem "rack-protection" -gem "rack-test" -gem "rack-flash3" -gem "tilt", "=1.3.3" -gem "sinatra", "=1.4.6" -gem "locale", "=2.1.0" +gem "bcrypt-ruby", "= 3.1.5" +gem "log4r", "= 1.1.10" +gem "ipaddress", "= 0.8.0" +gem "ruby_protobuf", "= 0.4.11" +gem "json", "= 1.8.1" +gem "datamapper" +gem "dm-aggregates" +gem "dm-do-adapter" +gem "dm-migrations" +gem "dm-postgres-adapter" +gem "dm-sqlite-adapter" +gem "dm-transactions" +gem "dm-types" +gem "dm-validations" +gem "sanitize", "= 2.1.0" +gem "rmail", "= 1.1.0" +gem "thin", "= 1.6.3" +gem "haml", "= 4.0.5" +gem "RedCloth", "= 4.2.9" +gem "rack", "= 1.5.2" +gem "rack-protection", "= 1.5.2" +gem "rack-flash3", "= 1.0.5" +gem "tilt", "= 1.4.1" +gem "sinatra", "~> 1.4.5" +gem "locale", "= 2.1.0" group :test do gem "simplecov", :require => false + gem "rack-test", "= 0.6.3" + gem "webmock", "= 1.19.0" + gem "timecop", "= 0.7.1" end diff --git a/Gemfile.lock b/Gemfile.lock index 8a4017f..437527d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,12 +2,15 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) - addressable (2.3.8) - bcrypt-ruby (3.0.1) - crack (0.4.2) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) + bcrypt (3.1.11) + bcrypt-ruby (3.1.5) + bcrypt (>= 3.1.3) + crack (0.4.3) safe_yaml (~> 1.0.0) - daemons (1.2.2) - data_objects (0.10.15) + daemons (1.2.4) + data_objects (0.10.17) addressable (~> 2.1) datamapper (1.2.0) dm-aggregates (~> 1.2.0) @@ -33,12 +36,12 @@ GEM dm-postgres-adapter (1.2.0) dm-do-adapter (~> 1.2.0) do_postgres (~> 0.10.6) - dm-serializer (1.2.0) + dm-serializer (1.2.2) dm-core (~> 1.2.0) - fastercsv (~> 1.5.4) - json (~> 1.5.4) - json_pure (~> 1.5.4) - multi_json (~> 1.0.3) + fastercsv (~> 1.5) + json (~> 1.6) + json_pure (~> 1.6) + multi_json (~> 1.0) dm-sqlite-adapter (1.2.0) dm-do-adapter (~> 1.2.0) do_sqlite3 (~> 0.10.6) @@ -46,98 +49,98 @@ GEM dm-core (~> 1.2.0) dm-transactions (1.2.0) dm-core (~> 1.2.0) - dm-types (1.2.0) - bcrypt-ruby (~> 3.0.0) + dm-types (1.2.2) + bcrypt-ruby (~> 3.0) dm-core (~> 1.2.0) - fastercsv (~> 1.5.4) - json (~> 1.5.4) - multi_json (~> 1.0.3) - stringex (~> 1.3.0) - uuidtools (~> 2.1.2) + fastercsv (~> 1.5) + json (~> 1.6) + multi_json (~> 1.0) + stringex (~> 1.4) + uuidtools (~> 2.1) dm-validations (1.2.0) dm-core (~> 1.2.0) - do_postgres (0.10.15) - data_objects (= 0.10.15) - do_sqlite3 (0.10.15) - data_objects (= 0.10.15) + do_postgres (0.10.17) + data_objects (= 0.10.17) + do_sqlite3 (0.10.17) + data_objects (= 0.10.17) docile (1.1.5) - eventmachine (1.0.7) + eventmachine (1.2.3) fastercsv (1.5.5) - haml (3.0.15) + haml (4.0.5) + tilt ipaddress (0.8.0) - json (1.5.4) - json_pure (1.5.5) - spruz (~> 0.2.8) + json (1.8.1) + json_pure (1.8.6) locale (2.1.0) - log4r (1.0.6) - multi_json (1.0.4) - nokogiri (1.5.11) - rack (1.6.0) + log4r (1.1.10) + mini_portile2 (2.1.0) + multi_json (1.12.1) + nokogiri (1.7.1) + mini_portile2 (~> 2.1.0) + public_suffix (2.0.5) + rack (1.5.2) rack-flash3 (1.0.5) rack - rack-protection (1.5.3) + rack-protection (1.5.2) rack rack-test (0.6.3) rack (>= 1.0) rmail (1.1.0) ruby_protobuf (0.4.11) safe_yaml (1.0.4) - sanitize (2.0.3) - nokogiri (>= 1.4.4, < 1.6) - simplecov (0.9.2) + sanitize (2.1.0) + nokogiri (>= 1.4.4) + simplecov (0.14.1) docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.9.0) - simplecov-html (0.9.0) - sinatra (1.4.6) - rack (~> 1.4) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) + sinatra (1.4.8) + rack (~> 1.5) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - spruz (0.2.13) - stringex (1.3.3) + stringex (1.5.1) thin (1.6.3) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) rack (~> 1.0) - tilt (1.3.3) - timecop (0.3.5) + tilt (1.4.1) + timecop (0.7.1) uuidtools (2.1.5) - webmock (1.7.6) - addressable (~> 2.2, > 2.2.5) - crack (>= 0.1.7) - xmpp4r (0.5.6) + webmock (1.19.0) + addressable (>= 2.3.6) + crack (>= 0.3.2) PLATFORMS ruby DEPENDENCIES - RedCloth - bcrypt-ruby (= 3.0.1) - datamapper (= 1.2.0) - dm-aggregates (= 1.2.0) - dm-do-adapter (= 1.2.0) - dm-migrations (= 1.2.0) - dm-postgres-adapter (= 1.2.0) - dm-sqlite-adapter (= 1.2.0) - dm-transactions (= 1.2.0) - dm-types (= 1.2.0) - dm-validations (= 1.2.0) - haml (= 3.0.15) + RedCloth (= 4.2.9) + bcrypt-ruby (= 3.1.5) + datamapper + dm-aggregates + dm-do-adapter + dm-migrations + dm-postgres-adapter + dm-sqlite-adapter + dm-transactions + dm-types + dm-validations + haml (= 4.0.5) ipaddress (= 0.8.0) - json (= 1.5.4) + json (= 1.8.1) locale (= 2.1.0) - log4r (= 1.0.6) - rack - rack-flash3 - rack-protection - rack-test + log4r (= 1.1.10) + rack (= 1.5.2) + rack-flash3 (= 1.0.5) + rack-protection (= 1.5.2) + rack-test (= 0.6.3) rmail (= 1.1.0) ruby_protobuf (= 0.4.11) - sanitize (= 2.0.3) + sanitize (= 2.1.0) simplecov - sinatra (= 1.4.6) + sinatra (~> 1.4.5) thin (= 1.6.3) - tilt (= 1.3.3) - timecop (= 0.3.5) - webmock (= 1.7.6) - xmpp4r (= 0.5.6) + tilt (= 1.4.1) + timecop (= 0.7.1) + webmock (= 1.19.0) diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb index aac5f69..ccc67aa 100644 --- a/lib/mauve/configuration_builders/person.rb +++ b/lib/mauve/configuration_builders/person.rb @@ -23,7 +23,6 @@ module Mauve is_attribute "password" is_attribute "sms" is_attribute "email" - is_attribute "xmpp" is_attribute "hipchat" is_flag_attribute "notify_when_on_holiday" @@ -109,8 +108,8 @@ module Mauve # Set up some default notify levels. # if person.urgent.nil? and person.normal.nil? and person.low.nil? - person.urgent = Proc.new { sms ; xmpp ; email } - person.normal = Proc.new { xmpp ; email } + person.urgent = Proc.new { sms ; email } + person.normal = Proc.new { email } person.low = Proc.new { email } end diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb index 35ac019..4939b03 100644 --- a/lib/mauve/notifier.rb +++ b/lib/mauve/notifier.rb @@ -1,6 +1,5 @@ require 'mauve/mauve_thread' require 'mauve/notifiers' -require 'mauve/notifiers/xmpp' module Mauve @@ -15,8 +14,7 @@ module Mauve include Singleton # Stop the notifier thread. This just makes sure that all the - # notifications in the buffer have been sent before closing the XMPP - # connection. + # notifications in the buffer have been sent. # def stop super @@ -25,11 +23,6 @@ module Mauve # Flush the queue. # main_loop - - if Configuration.current.notification_methods['xmpp'] - Configuration.current.notification_methods['xmpp'].close - end - end # @@ -69,43 +62,6 @@ module Mauve # # def main_loop - - # - # Make sure we're connected to the XMPP server if needed on every iteration. - # - xmpp = Configuration.current.notification_methods['xmpp'] - - if xmpp and !xmpp.ready? - # - # Connect to XMPP server - # - xmpp.connect - - # - # Join all chats and shit. Unless the connection failed. - # - Configuration.current.people.each do |username, person| - # - # Ignore people without XMPP stanzas. - # - next unless person.respond_to?(:xmpp) and person.xmpp - - # - # For each JID, either ensure they're on our roster, or that we're in - # that chat room. - # - jid = if xmpp.is_muc?(person.xmpp) - xmpp.join_muc(person.xmpp) - else - xmpp.ensure_roster_and_subscription!(person.xmpp) - end - - Configuration.current.people[username].xmpp = jid unless jid.nil? - - end if xmpp.ready? - - end - # # Cycle through the buffer. # diff --git a/lib/mauve/notifiers.rb b/lib/mauve/notifiers.rb index 383db5e..424b2c1 100644 --- a/lib/mauve/notifiers.rb +++ b/lib/mauve/notifiers.rb @@ -2,7 +2,6 @@ require 'mauve/notifiers/email' require 'mauve/notifiers/sms_default' require 'mauve/notifiers/sms_aql' require 'mauve/notifiers/sms_clockwork' -require 'mauve/notifiers/xmpp' require 'mauve/notifiers/hipchat' module Mauve diff --git a/lib/mauve/notifiers/templates/email_subject.txt.erb b/lib/mauve/notifiers/templates/email_subject.txt.erb index 802c711..45fda99 120000 --- a/lib/mauve/notifiers/templates/email_subject.txt.erb +++ b/lib/mauve/notifiers/templates/email_subject.txt.erb @@ -1 +1 @@ -xmpp.txt.erb \ No newline at end of file +sms.txt.erb \ No newline at end of file diff --git a/lib/mauve/notifiers/templates/hipchat.txt.erb b/lib/mauve/notifiers/templates/hipchat.txt.erb index 802c711..45fda99 120000 --- a/lib/mauve/notifiers/templates/hipchat.txt.erb +++ b/lib/mauve/notifiers/templates/hipchat.txt.erb @@ -1 +1 @@ -xmpp.txt.erb \ No newline at end of file +sms.txt.erb \ No newline at end of file diff --git a/lib/mauve/notifiers/templates/sms.txt.erb b/lib/mauve/notifiers/templates/sms.txt.erb deleted file mode 120000 index 802c711..0000000 --- a/lib/mauve/notifiers/templates/sms.txt.erb +++ /dev/null @@ -1 +0,0 @@ -xmpp.txt.erb \ No newline at end of file diff --git a/lib/mauve/notifiers/templates/sms.txt.erb b/lib/mauve/notifiers/templates/sms.txt.erb new file mode 100644 index 0000000..c148f41 --- /dev/null +++ b/lib/mauve/notifiers/templates/sms.txt.erb @@ -0,0 +1,22 @@ +<%=alert.id %>: <%= alert.update_type.upcase %> (<%= alert.level %>): <% +case alert.update_type +when "cleared" +%><%= alert.cleared_at.to_s_relative %><% +when "acknowledged" +%><%= alert.acknowledged_at.to_s_relative %> by <%= alert.acknowledged_by %> until <%= alert.will_unacknowledge_at.to_s_human %><% +else +%><%= alert.raised_at.to_s_relative %><% +end +%>: <%= alert.subject %> <%= alert.summary %><% +if alert.source != alert.subject +%> -- from <%= alert.source %><% +end +%>. <%=WebInterface.url_for(alert)%><% +if defined? was_suppressed and defined? will_suppress + if was_suppressed and not will_suppress +%> (Normal service for <%= alert.level %> alerts has resumed.)<% + elsif will_suppress and not was_suppressed +%> (Further <%= alert.level %> alerts suppressed until things calm down.)<% + end +end +%> diff --git a/lib/mauve/notifiers/templates/xmpp.html.erb b/lib/mauve/notifiers/templates/xmpp.html.erb deleted file mode 100644 index 7792bd9..0000000 --- a/lib/mauve/notifiers/templates/xmpp.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - -<%= alert.id%>: <%= alert.update_type.upcase %> (<%= alert.level %>): <% -case alert.update_type -when "cleared" -%><%= alert.cleared_at.to_s_relative %><% -when "acknowledged" -%><%= alert.acknowledged_at.to_s_relative %> by <%= alert.acknowledged_by %> until <%= alert.will_unacknowledge_at.to_s_human %><% -else -%><%= alert.raised_at.to_s_relative %><% -end -%>: <%= alert.subject %> <%= alert.summary %><% -if alert.source != alert.subject -%> -- from <%= alert.source %><% -end -%>.<% -if defined? was_suppressed and defined? will_suppress - if was_suppressed and not will_suppress -%>
Normal service for <%= alert.level %> alerts has resumed.<% - elsif will_suppress and not was_suppressed -%>
Further <%= alert.level %> alerts suppressed until things calm down.<% - end -end -%> diff --git a/lib/mauve/notifiers/templates/xmpp.txt.erb b/lib/mauve/notifiers/templates/xmpp.txt.erb deleted file mode 100644 index c148f41..0000000 --- a/lib/mauve/notifiers/templates/xmpp.txt.erb +++ /dev/null @@ -1,22 +0,0 @@ -<%=alert.id %>: <%= alert.update_type.upcase %> (<%= alert.level %>): <% -case alert.update_type -when "cleared" -%><%= alert.cleared_at.to_s_relative %><% -when "acknowledged" -%><%= alert.acknowledged_at.to_s_relative %> by <%= alert.acknowledged_by %> until <%= alert.will_unacknowledge_at.to_s_human %><% -else -%><%= alert.raised_at.to_s_relative %><% -end -%>: <%= alert.subject %> <%= alert.summary %><% -if alert.source != alert.subject -%> -- from <%= alert.source %><% -end -%>. <%=WebInterface.url_for(alert)%><% -if defined? was_suppressed and defined? will_suppress - if was_suppressed and not will_suppress -%> (Normal service for <%= alert.level %> alerts has resumed.)<% - elsif will_suppress and not was_suppressed -%> (Further <%= alert.level %> alerts suppressed until things calm down.)<% - end -end -%> diff --git a/lib/mauve/notifiers/xmpp.rb b/lib/mauve/notifiers/xmpp.rb deleted file mode 100644 index 8ab6d48..0000000 --- a/lib/mauve/notifiers/xmpp.rb +++ /dev/null @@ -1,837 +0,0 @@ -require 'log4r' -require 'xmpp4r' -require 'xmpp4r/roster' -require 'xmpp4r/muc' -# require 'xmpp4r/xhtml' -# require 'xmpp4r/discovery/helper/helper' -require 'mauve/notifiers/debug' - - - -# -# A couple of monkey patches to fix up all this nonsense. -# -module Jabber - # - # Monkey patch of the close commands. For good reasons, though I can't - # remember why. - # - class Stream - def close - # - # Just close - # - close! - end - - def close! - 10.times do - pr = 0 - @tbcbmutex.synchronize { pr = @processing } - break if pr == 0 - Thread::pass if pr > 0 - sleep 1 - end - - # Order Matters here! If this method is called from within - # @parser_thread then killing @parser_thread first would - # mean the other parts of the method fail to execute. - # That would be bad. So kill parser_thread last - @tbcbmutex.synchronize { @processing = 0 } - if @fd and !@fd.closed? - @fd.close - stop - end - @status = DISCONNECTED - end - end -end - - - - -module Mauve - module Notifiers - - # - # This is the Jabber/XMMP notifiers module. - # - module Xmpp - - # - # The default provider is XMMP, although this should really be broken out - # into its own provider to allow multple ways of doing XMPP. - # - class Default - - include Jabber - - # Atrtribute. - attr_reader :name - - # Atrtribute. - attr_accessor :password - - def initialize(name) - Jabber::logger = self.logger -# Jabber::debug = true -# Jabber::warnings = true - - @name = name - @mucs = {} - @roster = nil - @closing = false - @client = nil - end - - # The logger instance - # - # @return [Log4r::Logger] - def logger - # Give the logger a sane name - @logger ||= Log4r::Logger.new self.class.to_s.sub(/::Default$/,"") - end - - # Sets the client's JID - # - # @param [String] jid The JID required. - # @return [Jabber::JID] The client JID. - def jid=(jid) - @jid = JID.new(jid) - end - - # Connects to the XMPP server, and sets up the roster - # - # @return [Jabber::Client, NilClass] The connected client, or nil in the case of failure - def connect - logger.debug "Starting connection to #{@jid}" - - # Make sure we're disconnected. - self.close if @client.is_a?(Client) - - @client = Client.new(@jid) - - @closing = false - @client.connect - @client.auth_nonsasl(@password, false) - @roster = Roster::Helper.new(@client) - - # Unconditionally accept all roster add requests, and respond with a - # roster add + subscription request of our own if we're not subscribed - # already - @roster.add_subscription_request_callback do |ri, presence| - Thread.new do - if is_known_contact?(presence.from) - logger.info("Accepting subscription request from #{presence.from}") - @roster.accept_subscription(presence.from) - ensure_roster_and_subscription!(presence.from) - else - logger.info("Declining subscription request from #{presence.from}") - @roster.decline_subscription(presence.from) - end - end.join - end - - @client.add_message_callback do |m| - receive_message(m) - end - - @roster.wait_for_roster - - @client.send(Presence.new(nil, "Woo!").set_type(nil)) - - logger.info "Connected as #{@jid}" - - # @client.on_exception do |ex, stream, where| - # - # The XMPP4R exception clauses in Stream all close the stream, so - # we just need to reconnect. - # - # unless ex.nil? or @closing - # logger.warn(["Caught",ex.class,ex.to_s,"during XMPP",where].join(" ")) - # logger.debug ex.backtrace.join("\n") - # self.close - # end - # end - rescue StandardError => ex - logger.error "Connect failed #{ex.to_s}" - logger.debug ex.backtrace.join("\n") - self.close - @client = nil - end - - def stop - @client.stop - end - - # - # Closes the XMPP connection, if possible. Sets @client to nil. - # - # @return [NilClass] - def close - @closing = true - if @client - if @client.is_connected? - @mucs.each do |jid, muc| - muc[:client].exit("Goodbye!") if muc[:client].active? - end - @client.send(Presence.new(nil, "Goodbye!").set_type(:unavailable)) - end - @client.close! - end - @client = nil - end - - # Determines if the client is ready. - # - # @return [Boolean] - def ready? - @client.is_a?(Jabber::Client) and @client.is_connected? - end - - # Attempt to send an alert using XMPP. - # - # @param [String] destination The JID you're sending the alert to. This should be - # a bare JID in the case of an individual, or +muc:room@server+ for - # chatrooms (XEP0045). - # - # @param [Mauve::Alert] alert This is turned into a pretty - # message and sent to the destination as a message, if +conditions+ - # are met. - # - # @param [Array] all_alerts Currently ignored. - # - # @param [Hash] conditions Conditions that determine if an alert should be sent - # - # @option conditions [Array] :if_presence Checks whether the jid in question - # has a presence matching one or more of the choices - see - # Mauve::Notifiers::Xmpp::Default#check_jid_has_presence for options. - # - # @return [Boolean] - def send_alert(destination, alert, all_alerts, conditions = {}) - destination_jid = JID.new(destination) - - was_suppressed = conditions[:was_suppressed] || false - will_suppress = conditions[:will_suppress] || false - - if conditions && !check_alert_conditions(destination_jid, conditions) - logger.info("Alert conditions not met, not sending XMPP alert to #{destination_jid}") - return false - end - - template_file = File.join(File.dirname(__FILE__),"templates","xmpp.txt.erb") - - txt = if File.exists?(template_file) - ERB.new(File.read(template_file)).result(binding).chomp - else - logger.error("Could not find xmpp.txt.erb template") - alert.to_s - end - - template_file = File.join(File.dirname(__FILE__),"templates","xmpp.html.erb") - - xhtml = if File.exists?(template_file) - ERB.new(File.read(template_file)).result(binding).chomp - else - logger.error("Could not find xmpp.txt.erb template") - alert.to_s - end - - msg_type = (is_muc?(destination_jid) ? :groupchat : :chat) - - send_message(destination_jid, txt, xhtml, msg_type) - end - - # Sends a message to the destionation. - def send_message(jid, msg, html_msg=nil, msg_type=:chat) - return false unless self.ready? - - jid = JID.new(jid) unless jid.is_a?(JID) - - message = Message.new(jid) - message.body = msg - if html_msg - begin - html_msg = REXML::Document.new(html_msg) unless html_msg.is_a?(REXML::Document) - message.add_element(html_msg) - rescue REXML::ParseException - logger.error "Bad XHTML: #{html_msg.inspect}" - end - end - - message.to = jid - message.type = msg_type - - if message.type == :groupchat and is_muc?(jid) - jid = join_muc(jid.strip) - muc = @mucs[jid][:client] - - if muc - muc.send(message) - true - else - logger.warn "Failed to join MUC #{jid} when trying to send a message" - false - end - else - # - # We aren't interested in sending things to people who aren't online. - # - ensure_roster_and_subscription!(jid) - - if check_jid_has_presence(jid) - @client.send(message) - true - else - false - end - end - end - - # - # Joins a chat, and returns the stripped JID of the chat joined. - # - def join_muc(jid, password=nil) - self.connect unless self.ready? - - return unless self.ready? - - if jid.is_a?(String) and jid =~ /^muc:(.*)/ - jid = JID.new($1) - end - - unless jid.is_a?(JID) - logger.warn "#{jid} is not a MUC" - return - end - - jid.resource = @client.jid.resource if jid.resource.to_s.empty? - - if !@mucs[jid.strip] - - logger.debug("Adding new MUC client for #{jid}") - - @mucs[jid.strip] = {:jid => jid, :password => password, :client => Jabber::MUC::MUCClient.new(@client)} - - # Add some callbacks - @mucs[jid.strip][:client].add_message_callback do |m| - receive_message(m) - end - - @mucs[jid.strip][:client].add_private_message_callback do |m| - receive_message(m) - end - - end - - if !@mucs[jid.strip][:client].active? - # - # Make sure we have a resource. - # - @mucs[jid.strip][:client].join(jid, password) - - logger.info("Joined #{jid.strip}") - else - logger.debug("Already joined #{jid.strip}.") - end - - # - # Return the JID object - # - jid.strip - end - - # - # Checks whether the destination JID is a MUC. - # - def is_muc?(jid) - (jid.is_a?(JID) and @mucs.keys.include?(jid.strip)) or - (jid.to_s =~ /^muc:(.*)/) - - # - # It would be nice to use service discovery to determin this, but it - # turns out that it is shite in xmpp4r. It doesn't return straight - # away with an answer, making it a bit useless. Some sort of weird - # threading issue, I think. - # - # begin - # logger.warn caller.join("\n") - # cl = Discovery::Helper.new(@client) - # res = cl.get_info_for(jid.strip) - # @client.wait - # logger.warn "hello #{res.inspect}" - # res.is_a?(Discovery::IqQueryDiscoInfo) and res.identity.category == :conference - # rescue Jabber::ServerError => ex - # false - # end - end - - # - # Checks to see if the JID is in our roster, and whether we are - # subscribed to it or not. Will add to the roster and subscribe as - # is necessary to ensure both are true. - # - def ensure_roster_and_subscription!(jid) - self.connect unless self.ready? - - return unless self.ready? - - return jid if is_muc?(jid) - - jid = JID.new(jid) unless jid.is_a?(JID) - - ri = @roster.find(jid).values.first - @roster.add(jid, nil, true) if ri.nil? - - ri = @roster.find(jid).values.first - ri.subscribe unless [:to, :both, :remove].include?(ri.subscription) - ri.jid - rescue StandardError => ex - logger.error("Problem ensuring that #{jid} is subscribed and in mauve's roster: #{ex.inspect}") - nil - end - - protected - - def receive_message(msg) - # - # Don't talk to self - # - if @jid == msg.from or @mucs.any?{|jid, muc| muc.is_a?(Hash) and muc.has_key?(:client) and muc[:client].jid == msg.from} - return nil - end - - # We only want to hear messages from known contacts. - unless is_known_contact?(msg.from) - # ignore message - logger.info "Ignoring message from unknown contact #{msg.from}" - return nil - end - - case msg.type - when :error - receive_error_message(msg) - when :groupchat - receive_groupchat_message(msg) - else - receive_normal_message(msg) - end - end - - def receive_error_message(msg) - logger.warn("Caught XMPP error #{msg}") - nil - end - - def receive_normal_message(msg) - # - # Treat invites specially - # - if msg.x("jabber:x:conference") - # - # recieved an invite. Need to mangle the jid. - # - jid =JID.new(msg.x("jabber:x:conference").attribute("jid")) - # jid.resource = @client.jid.resource - logger.info "Received an invite to #{jid}" - unless join_muc(jid) - logger.warn "Failed to join MUC #{jid} following invitation" - return nil - end - elsif msg.body - # - # Received a message with a body. - # - jid = msg.from - end - - if jid - reply = parse_command(msg) - send_message(jid, reply, nil, msg.type) - end - end - - def receive_groupchat_message(msg) - # - # We only want group chat messages from MUCs we're already joined to, - # that we've not sent ourselves, that are not historical, and that - # match our resource or node in the body. - # - if @mucs[msg.from.strip][:client].is_a?(MUC::MUCClient) and - msg.x("jabber:x:delay") == nil and - (msg.body =~ /\b#{Regexp.escape(@mucs[msg.from.strip][:client].jid.resource)}\b/i or - msg.body =~ /\b#{Regexp.escape(@client.jid.node)}\b/i) - - receive_normal_message(msg) - end - end - - def parse_command(msg) - case msg.body - when /help(\s+\w+)?/i - do_parse_help(msg) - when /show\s?/i - do_parse_show(msg) - when /ack/i - do_parse_ack(msg) - when /clear/i - do_parse_clear(msg) - when /destroy\s?/i - "Sorry -- destroy has been disabled. Try \"clear\" instead." - else - File.executable?('/usr/games/fortune') ? `/usr/games/fortune -s -n 60`.chomp : "I'd love to stay and chat, but I'm really quite busy" - end - end - - def do_parse_help(msg) - msg.body =~ /help\s+(\w+)/i - cmd = $1 - - return case cmd - when /^show/ - < for