From 6e51920e844678535f14cfbc703ac89f62251de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20W=2E=20Crompton?= Date: Sun, 26 Aug 2018 16:56:01 +0200 Subject: [PATCH] Created packager for release Updated to listen on 0.0.0.0 --- Makefile | 18 ++++++++++++++++++ VERSION | 1 + modbusserver.go | 2 +- modbustcpd | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 VERSION create mode 100755 modbustcpd diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..565a44c --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ + +all: + go build + +release: all git-tag + tar jcf modbus-demo-`cat VERSION`.tar.bz2 modbustcp modbustcpd LICENSE README.md + +git-tag: bump + git tag `cat VERSION` + git push --tags + +bump: + echo `cat VERSION`+.1 |bc > VERSION.new + rm VERSION + mv VERSION.new VERSION + +upload: + scp modbus-demo-`cat VERSION`.tar.bz2 oplerno:/var/lib/lxd/containers/ateps-updates/rootfs/var/www/portage/distfiles/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c239c60 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.5 diff --git a/modbusserver.go b/modbusserver.go index 4a71156..35314c6 100644 --- a/modbusserver.go +++ b/modbusserver.go @@ -37,7 +37,7 @@ func main() { serv.RegisterFunctionHandler(4, ReadRegisters) serv.RegisterFunctionHandler(6, WriteRegisters) - err := serv.ListenTCP("127.0.0.1:502") + err := serv.ListenTCP(":502") if err != nil { log.Printf("%v\n", err) } diff --git a/modbustcpd b/modbustcpd new file mode 100755 index 0000000..0782d5d --- /dev/null +++ b/modbustcpd @@ -0,0 +1,47 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation, Daniel Crompton +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="checkconfig" +extra_started_commands="reload" + +: ${MODBUSD_PIDFILE:=/var/run/${SVCNAME}.pid} +: ${MODBUSD_BINARY:=/usr/sbin/modbustcp} + +depend() { + use logger dns +} + +checkconfig() { + return 0 +} + +start() { + checkconfig || return 1 + + ebegin "Starting ${SVCNAME}" + start-stop-daemon -b --start --exec "${MODBUSD_BINARY}" \ + --pidfile "${MODBUSD_PIDFILE}" \ + -- ${MODBUSD_OPTS} + eend $? +} + +stop() { + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return 1 + fi + + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --exec "${MODBUSD_BINARY}" \ + --pidfile "${MODBUSD_PIDFILE}" --quiet + eend $? +} + +reload() { + checkconfig || return 1 + ebegin "Reloading ${SVCNAME}" + start-stop-daemon --signal HUP \ + --exec "${MODBUSD_BINARY}" --pidfile "${MODBUSD_PIDFILE}" + eend $? +} +