From 17c95c01baff892010b96e72ba53d689dc8bfb95 Mon Sep 17 00:00:00 2001
From: Markus Frosch <markus.frosch@icinga.com>
Date: Fri, 30 Aug 2019 17:06:07 +0200
Subject: [PATCH] Add systemd service

---
 debian/control                  |  4 +++-
 debian/icinga-reporting.service | 11 +++++++++++
 debian/rules                    |  8 +++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 debian/icinga-reporting.service

diff --git a/debian/control b/debian/control
index 429cfcd..a60f739 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,9 @@ Source: icingaweb2-module-reporting
 Section: admin
 Priority: optional
 Maintainer: Icinga Development Team <info@icinga.com>
-Build-Depends: debhelper (>= 9)
+Build-Depends:
+  debhelper (>= 9),
+  dh-systemd
 Standards-Version: 3.9.8
 Homepage: https://www.icinga.com
 
diff --git a/debian/icinga-reporting.service b/debian/icinga-reporting.service
new file mode 100644
index 0000000..061f268
--- /dev/null
+++ b/debian/icinga-reporting.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Icinga Reporting Scheduler
+
+[Service]
+Type=simple
+User=www-data
+ExecStart=/usr/bin/icingacli reporting schedule run
+Restart=on-success
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/rules b/debian/rules
index 6235ac6..ee78c76 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,11 +5,17 @@ MODULE_NAME := reporting
 MODULE_PATH := /usr/share/icingaweb2/modules/$(MODULE_NAME)
 
 %:
-	dh $@
+	dh $@ --with systemd
 
 override_dh_auto_install:
 	mkdir debian/tmp
 	mkdir -p debian/tmp$(MODULE_PATH)
 	find -maxdepth 1 ! -name debian ! -name ".*" -exec cp -rvt debian/tmp$(MODULE_PATH) {} \;
 
+override_dh_systemd_enable:
+	dh_systemd_enable --no-enable --name=icinga-$(MODULE_NAME)
+
+override_dh_systemd_start:
+	dh_systemd_start --no-start --name=icinga-$(MODULE_NAME)
+
 # vi: ts=4 sw=4 noexpandtab :
-- 
GitLab