From 9b97ef37a25e3c985170154bdcfecf895afcd943 Mon Sep 17 00:00:00 2001
From: Bernd Helm <bernd.helm@helmundwalter.de>
Date: Mon, 3 Nov 2014 18:05:58 +0100
Subject: [PATCH] Added systemd service files

---
 files/glbd.cfg      |  2 ++
 files/glbd.service  | 18 ++++++++++++++++++
 files/glbd@.service | 23 +++++++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 files/glbd.service
 create mode 100644 files/glbd@.service

diff --git a/files/glbd.cfg b/files/glbd.cfg
index 3d62618..898e3a1 100644
--- a/files/glbd.cfg
+++ b/files/glbd.cfg
@@ -4,6 +4,8 @@
 #
 # On Debian  and derivatives it should be placed in /etc/default/glbd
 #
+# On Archlinux it should be placed in /etc/conf.d/glbd
+#
 # All settings besides LISTEN_ADDR are optional.
 #
 
diff --git a/files/glbd.service b/files/glbd.service
new file mode 100644
index 0000000..84d6957
--- /dev/null
+++ b/files/glbd.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Galera Load Balancer Service
+After=network.target
+
+[Service]
+#adjust the EnvironmentFile variable for your distribution
+# On Red Hat and derivatives it should be /etc/sysconfig/glbd
+#
+# On Debian  and derivatives it should be /etc/default/glbd
+#
+# On ArchLinux it should be /etc/conf.d/glbd
+#
+EnvironmentFile=/etc/conf.d/glbd
+Type=simple
+ExecStart=/usr/sbin/glbd $CONTROL_FIFO $CONTROL_ADDR $OTHER_OPTIONS $MAX_CONN $THREADS $LISTEN_ADDR $DEFAULT_TARGETS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/files/glbd@.service b/files/glbd@.service
new file mode 100644
index 0000000..e75f3d8
--- /dev/null
+++ b/files/glbd@.service
@@ -0,0 +1,23 @@
+# This systemd file is for the case when you want to run different glbd instances on one machine.
+# copy the default config file to /etc/syconfig/glbd@yourname (distribution specific, see below) 
+# and enable or start the service with "systemctl enable glbd@yourname"
+#
+
+[Unit]
+Description=Galera Load Balancer Service %i
+After=network.target
+
+[Service]
+#adjust the EnvironmentFile variable for your distribution
+# On Red Hat and derivatives it should be /etc/sysconfig/glbd@%i
+#
+# On Debian  and derivatives it should be /etc/default/glbd@%i
+#
+# On ArchLinux it should be /etc/conf.d/glbd@%i
+#
+EnvironmentFile=/etc/conf.d/glbd@%i
+Type=simple
+ExecStart=/usr/sbin/glbd $CONTROL_FIFO $CONTROL_ADDR $OTHER_OPTIONS $MAX_CONN $THREADS $LISTEN_ADDR $DEFAULT_TARGETS
+
+[Install]
+WantedBy=multi-user.target