Package: wnpp
Severity: wishlist

* Package name    : influxdb-relay
  Version         : 0.0~20160928.0.535181e
  Upstream Author : InfluxData
* URL             : https://github.com/influxdata/influxdb-relay
* License         : Expat
  Programming Lang: Go
  Description     : a basic high availability layer for InfluxDB

  This daemon listens for InfluxDB requests and forwards them to one or
  more InfluxDB servers, allowing to replicate for example writes requests
  to multiple destinations.


This package is helpful if you are deploying InfluxDB on a cluster
and need some kind of basic replication and HA setup.

Attached a working and tested packaging patch (execept for the systemd
service file), where only the ITP bug number needs to be filled in the
debian/changelog, Maintainer changed, and Vcs fields added.

Thanks,
Guillem
From 4701fbd59906b3f12868f2fd40d8a46dbe02ac6e Mon Sep 17 00:00:00 2001
From: Guillem Jover <gjo...@sipwise.com>
Date: Wed, 28 Sep 2016 16:24:34 +0200
Subject: [PATCH] Initial packaging

---
 debian/changelog                                   |   5 +
 debian/compat                                      |   1 +
 debian/control                                     |  44 ++++++++
 debian/copyright                                   |  32 ++++++
 ...lang-github-influxdb-influxdb-relay-dev.install |   1 +
 ...golang-github-influxdb-influxdb-relay-dev.links |   1 +
 debian/influxdb-relay.conf                         |  54 ++++++++++
 debian/influxdb-relay.dirs                         |   2 +
 debian/influxdb-relay.init                         | 120 +++++++++++++++++++++
 debian/influxdb-relay.install                      |   2 +
 debian/influxdb-relay.lintian-overrides            |   5 +
 debian/influxdb-relay.logrotate                    |   8 ++
 debian/influxdb-relay.manpages                     |   1 +
 debian/influxdb-relay.postinst                     |  44 ++++++++
 debian/influxdb-relay.postrm                       |  31 ++++++
 debian/influxdb-relay.service                      |  16 +++
 debian/manpages/influxdb-relay.1                   |  13 +++
 debian/rules                                       |  12 +++
 debian/source/format                               |   1 +
 19 files changed, 393 insertions(+)
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/golang-github-influxdb-influxdb-relay-dev.install
 create mode 100644 debian/golang-github-influxdb-influxdb-relay-dev.links
 create mode 100644 debian/influxdb-relay.conf
 create mode 100644 debian/influxdb-relay.dirs
 create mode 100644 debian/influxdb-relay.init
 create mode 100644 debian/influxdb-relay.install
 create mode 100644 debian/influxdb-relay.lintian-overrides
 create mode 100644 debian/influxdb-relay.logrotate
 create mode 100644 debian/influxdb-relay.manpages
 create mode 100644 debian/influxdb-relay.postinst
 create mode 100644 debian/influxdb-relay.postrm
 create mode 100644 debian/influxdb-relay.service
 create mode 100644 debian/manpages/influxdb-relay.1
 create mode 100755 debian/rules
 create mode 100644 debian/source/format

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..eb775b4
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+influxdb-relay (0.0~20160928.0.535181e-1) UNRELEASED; urgency=medium
+
+  * Initial release. (Closes: #NNNNNN)
+
+ -- Guillem Jover <gjo...@sipwise.com>  Wed, 28 Sep 2016 14:21:32 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..609b68f
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,44 @@
+Source: influxdb-relay
+Section: database
+Priority: extra
+Homepage: https://github.com/influxdata/influxdb-relay
+Maintainer: Sipwise Development Team <supp...@sipwise.com>
+Build-Depends:
+ debhelper (>= 9),
+ dh-golang (>= 1.9),
+ golang-go,
+# Golang libraries below - Shared deps with dev package
+ golang-github-influxdb-influxdb-dev,
+ golang-github-naoina-go-stringutil-dev,
+ golang-github-naoina-toml-dev,
+Standards-Version: 3.9.8
+
+Package: golang-github-influxdb-influxdb-relay-dev
+Architecture: all
+Pre-Depends:
+ ${misc:Pre-Depends}
+Depends:
+ ${misc:Depends},
+ golang-github-influxdb-influxdb-dev,
+ golang-github-naoina-go-stringutil-dev,
+ golang-github-naoina-toml-dev,
+Built-Using: ${misc:Built-Using}
+Description:  a basic high availability layer for InfluxDB -- development files
+ This daemon listens for InfluxDB requests and forwards them to one or
+ more InfluxDB servers, allowing to replicate for example writes requests
+ to multiple destination InfluxDB servers.
+ .
+ This is the development package.
+
+Package: influxdb-relay
+Architecture: any
+Depends:
+ ${shlibs:Depends},
+ ${misc:Depends},
+ lsb-base (>= 3.0-6),
+ adduser,
+Built-Using: ${misc:Built-Using}
+Description: a basic high availability layer for InfluxDB
+ This daemon listens for InfluxDB requests and forwards them to one or
+ more InfluxDB servers, allowing to replicate for example writes requests
+ to multiple destination InfluxDB servers.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..9535d44
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,32 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Source: https://github.com/influxdata/influxdb-relay
+Upstream-Name: influxdb-relay
+
+Files: *
+Copyright:
+ Copyright © 2016 InfluxData
+License: Expat
+
+Files: debian/*
+Copyright:
+ Copyright © 2016 Sipwise GmbH, Austria
+License: Expat
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
diff --git a/debian/golang-github-influxdb-influxdb-relay-dev.install b/debian/golang-github-influxdb-influxdb-relay-dev.install
new file mode 100644
index 0000000..1237e8d
--- /dev/null
+++ b/debian/golang-github-influxdb-influxdb-relay-dev.install
@@ -0,0 +1 @@
+usr/share/gocode/src usr/share/gocode
diff --git a/debian/golang-github-influxdb-influxdb-relay-dev.links b/debian/golang-github-influxdb-influxdb-relay-dev.links
new file mode 100644
index 0000000..50da994
--- /dev/null
+++ b/debian/golang-github-influxdb-influxdb-relay-dev.links
@@ -0,0 +1 @@
+usr/share/gocode/src/github.com/influxdata/influxdb-relay usr/share/gocode/src/github.com/influxdb/influxdb-relay
diff --git a/debian/influxdb-relay.conf b/debian/influxdb-relay.conf
new file mode 100644
index 0000000..14e1fb0
--- /dev/null
+++ b/debian/influxdb-relay.conf
@@ -0,0 +1,54 @@
+### Welcome to the InfluxDB-Relay configuration file.
+
+# Standard
+
+#[[http]]
+#name = "example-http"
+#bind-addr = "127.0.0.1:9096"
+#output = [
+#    { name="local1", location = "http://127.0.0.1:8086/write"; },
+#    { name="local2", location = "http://127.0.0.1:7086/write"; },
+#]
+#
+#[[udp]]
+#name = "example-udp"
+#bind-addr = "127.0.0.1:9096"
+#read-buffer = 0 # default
+#output = [
+#    { name="local1", location="127.0.0.1:8089", mtu=512 },
+#    { name="local2", location="127.0.0.1:7089", mtu=1024 },
+#]
+
+# Buffered
+
+#[[http]]
+#name = "example-http-buffered"
+#bind-addr = "127.0.0.1:9096"
+#output = [
+#    { name="local1", location = "http://127.0.0.1:8086/write";, buffer-size-mb = 100, max-batch-kb = 50, max-delay-interval = "5s" },
+#    { name="local2", location = "http://127.0.0.1:7086/write";, buffer-size-mb = 100, max-batch-kb = 50, max-delay-interval = "5s" },
+#]
+
+# The relay can also be used to dual write data to Kapacitor
+#
+# There are a few advantages of using the relay instead of relying on InfluxDB subscriptions
+#
+# 1. Traffic is HTTP/TCP meaning you don't have to worry about dropped UDP packets
+# 2. Less load on InfluxDB since it doesn't have to fork the data.
+# 3. Slighly lower latency since there is one less hop.
+#
+# Kapacitor is wire compatible with InfluxDB for writes.
+# This means you can add a Kapacitor instance to the output list as if it were an InfluxDB instance.
+#
+
+# This example config sends all writes to
+# two InfluxDB hosts and a single Kapacitor host.
+#[[http]]
+#name = "kapacitor-http"
+#bind-addr = "0.0.0.0:9096"
+#default-retention-policy = "default"
+#output = [
+#    { name="influxdb1", location = "http://influxdb1:8086/write"; },
+#    { name="influxdb2", location = "http://influxdb2:8086/write"; },
+#    { name="kapacitor1", location = "http://kapacitor1:9092/write"; },
+#]
diff --git a/debian/influxdb-relay.dirs b/debian/influxdb-relay.dirs
new file mode 100644
index 0000000..8a147b7
--- /dev/null
+++ b/debian/influxdb-relay.dirs
@@ -0,0 +1,2 @@
+var/lib/influxdb-relay
+var/log/influxdb-relay
diff --git a/debian/influxdb-relay.init b/debian/influxdb-relay.init
new file mode 100644
index 0000000..64783cf
--- /dev/null
+++ b/debian/influxdb-relay.init
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:          influxdb-relay
+# Required-Start:    $network $local_fs $remote_fs
+# Required-Stop:     $network $local_fs $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Basic HA layer for InfluxDB
+# Description:       InfluxDB-Relay is a basic HA layer for InfluxDB. With
+#                    the right architecture and and disaster recovery
+#                    processes, this achieves a highly available setup.
+### END INIT INFO
+
+# If you modify this, please make sure to also edit influxdb.service.
+
+# Command-line options that can be set in /etc/default/influxdb-relay.
+# These will override any config file values.
+INFLUXDB_RELAY_OPTS=
+NAME=influxdb-relay
+
+USER=influxdb
+GROUP=influxdb
+
+if [ -r /lib/lsb/init-functions ]; then
+    . /lib/lsb/init-functions
+fi
+
+DEFAULT=/etc/default/$NAME
+
+if [ -r $DEFAULT ]; then
+    . $DEFAULT
+fi
+
+if [ -z "$STDOUT" ]; then
+    STDOUT=/dev/null
+fi
+if [ ! -f "$STDOUT" ]; then
+    mkdir -p $(dirname $STDOUT)
+fi
+
+if [ -z "$STDERR" ]; then
+    STDERR=/var/log/$NAME/$NAME.log
+fi
+if [ ! -f "$STDERR" ]; then
+    mkdir -p $(dirname $STDERR)
+fi
+
+OPEN_FILE_LIMIT=65536
+
+# Process name ( For display )
+DESC=database
+
+# Daemon name, where is the actual executable
+DAEMON=/usr/bin/$NAME
+
+# pid file for the daemon
+PIDFILE=/var/run/$NAME/$NAME.pid
+PIDDIR=$(dirname $PIDFILE)
+
+if [ ! -d "$PIDDIR" ]; then
+    mkdir -p $PIDDIR
+    chown $USER:$GROUP $PIDDIR
+fi
+
+# Configuration file
+CONFIG=/etc/$NAME/$NAME.conf
+
+# If the daemon is not there, then exit.
+[ -x $DAEMON ] || exit 0
+
+case $1 in
+    start)
+        log_daemon_msg "Starting $DESC" "$NAME"
+
+        # Bump the file limits, before launching the daemon. These will carry
+        # over to launched processes.
+        ulimit -n $OPEN_FILE_LIMIT
+        if [ $? -ne 0 ]; then
+            log_progress_msg "set open file limit to $OPEN_FILE_LIMIT"
+            log_end_msg 1
+            exit 1
+        fi
+
+        start-stop-daemon --start --quiet --oknodo --exec $DAEMON \
+          --user $USER --chuid $GROUP:$USER \
+          --pidfile $PIDFILE --make-pidfile --background --no-close \
+          -- -config $CONFIG $INFLUXD_RELAY_OPTS \
+          >>$STDOUT 2>>$STDERR
+
+        log_end_msg $?
+        ;;
+
+    stop)
+        log_daemon_msg "Stopping $DESC" "$NAME"
+
+        start-stop-daemon --stop --quiet --oknodo --exec $DAEMON \
+          --user $USER --pidfile $PIDFILE --remove-pidfile
+
+        log_end_msg $?
+        ;;
+
+    restart|force-reload)
+        log_daemon_msg "Restarting $DESC" "$NAME"
+        # Restart the daemon.
+        $0 stop && sleep 2 && $0 start
+        $0 status || errcode=$?
+        log_end_msg $errcode
+        ;;
+
+    status)
+        status_of_proc $DAEMON $NAME
+        ;;
+
+    *)
+        # For invalid arguments, print the usage message.
+        echo "Usage: $0 {start|stop|force-reload|restart|status}"
+        exit 2
+        ;;
+esac
diff --git a/debian/influxdb-relay.install b/debian/influxdb-relay.install
new file mode 100644
index 0000000..75b07ed
--- /dev/null
+++ b/debian/influxdb-relay.install
@@ -0,0 +1,2 @@
+usr/bin/influxdb-relay usr/bin
+debian/influxdb-relay.conf etc/influxdb-relay
diff --git a/debian/influxdb-relay.lintian-overrides b/debian/influxdb-relay.lintian-overrides
new file mode 100644
index 0000000..f804d2a
--- /dev/null
+++ b/debian/influxdb-relay.lintian-overrides
@@ -0,0 +1,5 @@
+# The Go compiler is currently unable to produce read-only relocations
+# (it produces static binaries).
+hardening-no-bindnow usr/bin/influxdb-relay
+hardening-no-pie usr/bin/influxdb-relay
+hardening-no-relro usr/bin/influxdb-relay
diff --git a/debian/influxdb-relay.logrotate b/debian/influxdb-relay.logrotate
new file mode 100644
index 0000000..17010f0
--- /dev/null
+++ b/debian/influxdb-relay.logrotate
@@ -0,0 +1,8 @@
+/var/log/influxdb-relay/influxdb-relay.log {
+    daily
+    rotate 7
+    missingok
+    dateext
+    copytruncate
+    compress
+}
diff --git a/debian/influxdb-relay.manpages b/debian/influxdb-relay.manpages
new file mode 100644
index 0000000..524e21d
--- /dev/null
+++ b/debian/influxdb-relay.manpages
@@ -0,0 +1 @@
+debian/manpages/influxdb-relay.1
diff --git a/debian/influxdb-relay.postinst b/debian/influxdb-relay.postinst
new file mode 100644
index 0000000..a13758e
--- /dev/null
+++ b/debian/influxdb-relay.postinst
@@ -0,0 +1,44 @@
+#!/bin/sh
+# postinst script for influxdb
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+configure|reconfigure)
+  # Create an influxdb group and user.
+  if ! getent passwd influxdb >/dev/null; then
+    adduser --system --home /var/lib/influxdb --no-create-home influxdb
+    addgroup --system influxdb
+    adduser influxdb influxdb
+  fi
+
+  if [ -d /var/lib/influxdb-relay ]; then
+    chown -R influxdb:influxdb /var/lib/influxdb-relay
+  fi
+
+  if [ -d /var/log/influxdb-relay ]; then
+    chown -R influxdb:influxdb /var/log/influxdb-relay
+  fi
+
+  # Create rundir.
+  mkdir -p /var/run/influxdb-relay
+  chown -R influxdb:influxdb /var/run/influxdb-relay
+  ;;
+
+abort-upgrade|abort-remove|abort-deconfigure)
+  ;;
+
+*)
+  echo "postinst called with unknown argument '$1'" >&2
+  exit 1
+  ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/influxdb-relay.postrm b/debian/influxdb-relay.postrm
new file mode 100644
index 0000000..c5d3a01
--- /dev/null
+++ b/debian/influxdb-relay.postrm
@@ -0,0 +1,31 @@
+#!/bin/sh
+# postrm script for influxdb
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+  # Always remove /var/run dir.
+  rm -rf /var/run/influxdb-relay
+
+  # Only remove /var/lib and /var/log dirs on purge.
+  if [ "$1" = "purge" ] ; then
+    rm -rf /var/lib/influxdb-relay
+    rm -rf /var/log/influxdb-relay
+  fi
+  ;;
+
+*)
+  echo "postrm called with unknown argument '$1'" >&2
+  exit 1
+  ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/influxdb-relay.service b/debian/influxdb-relay.service
new file mode 100644
index 0000000..28345df
--- /dev/null
+++ b/debian/influxdb-relay.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=InfluxDB-Relay is a basic HA layer for InfluxDB
+After=network.target
+Documentation=man:influxdb-relay(1)
+
+[Service]
+User=influxdb
+Group=influxdb
+LimitNOFILE=65536
+EnvironmentFile=-/etc/default/influxdb-relay
+ExecStart=/usr/bin/influxdb-relay -config /etc/influxdb-relay/influxdb-relay.conf $INFLUXDB_RELAY_OPTS
+KillMode=control-group
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/manpages/influxdb-relay.1 b/debian/manpages/influxdb-relay.1
new file mode 100644
index 0000000..970dd1e
--- /dev/null
+++ b/debian/manpages/influxdb-relay.1
@@ -0,0 +1,13 @@
+.TH influxdb\-relay 8 "2016-09-28" "0.0~20160928.0.535181e" "influxdata"
+.SH NAME
+influxdb-relay \- Basic HA layer for InfluxDB Server
+.SH SYNOPSIS
+.BR influxdb\-relay " [\fIoptions\fP...]"
+.SH DESCRIPTION
+influxdb-relay provides a basic HA layer for InfluxDB.
+.SH OPTIONS
+.TP
+.BR \-config " \fIpath\fP"
+Set the configuration file
+.SH SEE ALSO
+influxd(1)
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..543b33a
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,12 @@
+#!/usr/bin/make -f
+
+include /usr/share/dpkg/pkg-info.mk
+
+export DH_GOLANG_GO_GENERATE := 1
+export DH_GOPKG := github.com/influxdata/influxdb-relay
+
+%:
+	dh $@ --buildsystem=golang --with=golang --builddirectory=_build
+
+override_dh_auto_build:
+	dh_auto_build -- -ldflags="-X main.version=$(DEB_VERSION_UPSTREAM)"
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
-- 
2.9.3

_______________________________________________
Pkg-go-maintainers mailing list
Pkg-go-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-go-maintainers

Reply via email to