diff --git a/.gitignore b/.gitignore index 4518ef9..f2b3341 100644 --- a/.gitignore +++ b/.gitignore @@ -14,15 +14,17 @@ /config.status /config.sub /configure -/debian/daliserver.debhelper.log -/debian/daliserver.postinst.debhelper -/debian/daliserver.postrm.debhelper -/debian/daliserver.prerm.debhelper -/debian/daliserver.substvars +/debian/.debhelper/ +/debian/*.debhelper.log +/debian/*.debhelper +/debian/*.substvars /debian/daliserver/ +/debian/daliserver-upstart/ +/debian/daliserver-systemd/ /debian/files /debian/autoreconf.* /debian/.debhelper +/debian/debhelper-build-stamp /depcomp /install-sh /missing diff --git a/debian/control b/debian/control index 583d4f0..b46ec62 100644 --- a/debian/control +++ b/debian/control @@ -12,9 +12,35 @@ Vcs-Browser: https://github.com/onitake/daliserver Package: daliserver Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base -Description: Command multiplexing server for DALI lighting buses - Exposes a DALI (Digital Addressable Lighting Interface) bus to the - local machine by interfacing with the Tridonic DALI USB adapter. - . - Multiple clients can connect to the multiplexer to send commands to and - receive responses from devices connected to the bus. +Conflicts: daliserver-upstart, daliserver-systemd +Description: daliserver + daliserver is a command multiplexing server for the Tridonic DALI USB adapter, + allowing access to a DALI bus from any USB-equipped computer that supports + libusb. This package includes init scripts for sysvinit-based systems, or + systems that include a sysvinit compatibility layer. Only one DALI USB + adapter is supported at a time by this package, and adapters cannot be + hotplugged. + +Package: daliserver-upstart +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, upstart +Conflicts: daliserver, daliserver-systemd +Replaces: daliserver +Description: daliserver-upstart + daliserver is a command multiplexing server for the Tridonic DALI USB adapter, + allowing access to a DALI bus from any USB-equipped computer that supports + libusb. This package includes init scripts for upstart-based systems. + Multiple simultaneous DALI USB adapters are supported, and adapters can + be hotplugged. + +Package: daliserver-systemd +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, systemd (>= 236) +Conflicts: daliserver, daliserver-upstart +Replaces: daliserver +Description: daliserver + daliserver is a command multiplexing server for the Tridonic DALI USB adapter, + allowing access to a DALI bus from any USB-equipped computer that supports + libusb. This package includes init scripts for systemd-based systems. + Multiple simultaneous DALI USB adapters are supported, and adapters can + be hotplugged. diff --git a/debian/daliserver-systemd-start b/debian/daliserver-systemd-start new file mode 100755 index 0000000..3d4c064 --- /dev/null +++ b/debian/daliserver-systemd-start @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +DEVPATH=/"$(/bin/systemd-escape --unescape ${1})" +BUSNUM=$(cat ${DEVPATH}/busnum) +DEVNUM=$(cat ${DEVPATH}/devnum) +ID_SERIAL_SHORT=$(cat ${DEVPATH}/serial) + +source /etc/default/daliserver-systemd + +exec /usr/bin/daliserver $DALISERVER_OPTS -u $BUSNUM:$DEVNUM diff --git a/debian/daliserver-systemd.default b/debian/daliserver-systemd.default new file mode 100644 index 0000000..f2745a0 --- /dev/null +++ b/debian/daliserver-systemd.default @@ -0,0 +1,12 @@ +# Additional options for daliserver +# -n enables testing mode without USB connectivity +# -l sets the listening address (use 0.0.0.0 to listen on all interfaces) +# -p changes the port +# -f sets the log file name +DALISERVER_OPTS="-f /var/log/daliserver.log" + +# Options set based on serial number of DALI USB for -systemd package variant: +case "$ID_SERIAL_SHORT" in +# 000030A1) DALISERVER_OPTS="-p 55826 -f /var/log/daliserver-cellar.log" ;; +# 0000249A) DALISERVER_OPTS="-p 55827 -f /var/log/daliserver-groundfloor.log" ;; +esac diff --git a/debian/daliserver-systemd.install b/debian/daliserver-systemd.install new file mode 100644 index 0000000..289ee19 --- /dev/null +++ b/debian/daliserver-systemd.install @@ -0,0 +1,2 @@ +debian/daliserver-systemd@.service lib/systemd/system +debian/daliserver-systemd-start usr/lib/daliserver-systemd/ diff --git a/debian/daliserver-systemd.postinst b/debian/daliserver-systemd.postinst new file mode 100644 index 0000000..230725e --- /dev/null +++ b/debian/daliserver-systemd.postinst @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true +fi diff --git a/debian/daliserver-systemd.postrm b/debian/daliserver-systemd.postrm new file mode 100644 index 0000000..230725e --- /dev/null +++ b/debian/daliserver-systemd.postrm @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true +fi diff --git a/debian/daliserver-systemd.udev b/debian/daliserver-systemd.udev new file mode 100644 index 0000000..3dba275 --- /dev/null +++ b/debian/daliserver-systemd.udev @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="17b5", ATTR{idProduct}=="0020", TAG+="systemd", ENV{SYSTEMD_WANTS}="daliserver-systemd@.service" diff --git a/debian/daliserver-systemd@.service b/debian/daliserver-systemd@.service new file mode 100644 index 0000000..b2cfe13 --- /dev/null +++ b/debian/daliserver-systemd@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Command multiplexing server for Tridonic DALI USB on %i +BindsTo=%i.device +After=%i.device network.target + +[Service] +ExecStart=/usr/lib/daliserver-systemd/daliserver-systemd-start %i diff --git a/debian/daliserver-upstart.default b/debian/daliserver-upstart.default new file mode 100644 index 0000000..46e751d --- /dev/null +++ b/debian/daliserver-upstart.default @@ -0,0 +1,12 @@ +# Additional options for daliserver +# -n enables testing mode without USB connectivity +# -l sets the listening address (use 0.0.0.0 to listen on all interfaces) +# -p changes the port +# -f sets the log file name +DALISERVER_OPTS="-f /var/log/daliserver.log" + +# Options set based on serial number of DALI USB for -upstart package variant: +case "$ID_SERIAL_SHORT" in +# 000030A1) DALISERVER_OPTS="-p 55826 -f /var/log/daliserver-cellar.log" ;; +# 0000249A) DALISERVER_OPTS="-p 55827 -f /var/log/daliserver-groundfloor.log" ;; +esac diff --git a/debian/daliserver-upstart.upstart b/debian/daliserver-upstart.upstart new file mode 100644 index 0000000..85a0a48 --- /dev/null +++ b/debian/daliserver-upstart.upstart @@ -0,0 +1,23 @@ +# daliserver +# +# daliserver is a command multiplexing server for the Tridonic DALI +# USB adapter, allowing access to a DALI bus from any USB-equipped +# computer that supports libusb. + +description "Command multiplexing server for Tridonic DALI USB" +author "Gregor Riepl " + +start on usb-device-added ID_MODEL_ID='0020' ID_VENDOR_ID='17b5' +stop on usb-device-removed ID_MODEL_ID='0020' ID_VENDOR_ID='17b5' + +instance daliserver:$BUSNUM:$DEVNUM + +respawn + +# The device serial number is in ID_SERIAL_SHORT; this can be +# used in /etc/default/daliserver to set options per device. + +script + . /etc/default/daliserver-upstart + exec /usr/bin/daliserver $DALISERVER_OPTS -u $BUSNUM:$DEVNUM +end script diff --git a/debian/rules b/debian/rules index 63844c9..259a85e 100755 --- a/debian/rules +++ b/debian/rules @@ -4,3 +4,12 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: dh $@ --with autoreconf + +override_dh_auto_install: + dh_auto_install -p daliserver --destdir debian/daliserver + dh_auto_install -p daliserver-upstart --destdir debian/daliserver-upstart + dh_auto_install -p daliserver-systemd --destdir debian/daliserver-systemd + +override_dh_installinit: + dh_installinit -p daliserver + dh_installinit -p daliserver-upstart -p daliserver-systemd --no-start