From eaded178c3e2046ac8e468ed2f4d21398e218191 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 17 Oct 2015 11:57:32 +0100 Subject: [PATCH] update Debian package metadata for jessie --- debian/autoradio.default | 25 +++++-------- debian/autoradio.radiod.service | 13 +++++++ debian/autoradio.redirectord.service | 13 +++++++ debian/control | 4 +-- debian/rules | 45 +++++++++++------------ debian/services/lib.sh | 54 ---------------------------- debian/services/radiod | 11 ------ debian/services/redirectord | 11 ------ 8 files changed, 57 insertions(+), 119 deletions(-) create mode 100644 debian/autoradio.radiod.service create mode 100644 debian/autoradio.redirectord.service delete mode 100644 debian/services/lib.sh delete mode 100755 debian/services/radiod delete mode 100755 debian/services/redirectord diff --git a/debian/autoradio.default b/debian/autoradio.default index 2d79a488..8c176d25 100644 --- a/debian/autoradio.default +++ b/debian/autoradio.default @@ -1,25 +1,18 @@ -# Defaults for autoradio initscript -# sourced by /etc/init.d/autoradio -# installed at /etc/default/autoradio by the maintainer scripts - -# -# This is a POSIX shell fragment -# # Set your base domain name here. -DOMAIN="" +#DOMAIN="--domain=" -# Set your public IP if necessary (otherwise we'll try to resolve -# if your fully-qualified hostname). -#PUBLIC_IP="" +# Set your public IP if necessary. +#PUBLIC_IP="--ip=" -# Name of the outbound network interface (if unset, we'll try to -# figure it out automatically based on the value of PUBLIC_IP). -#INTERFACE="eth0" +# Name of the outbound network interface (if unset, radiod will try to +# figure it out automatically). +#INTERFACE="--interface=eth0" -# Set the etcd servers to connect to (default: etcd.$DOMAIN). +# Set the etcd servers to connect to (default: localhost:2379). #ETCD_SERVER="" # Additional options that are passed to specific daemons. #RADIOD_OPTIONS="--bwlimit=1000" -#REDIRECTORD_OPTIONS="" +RADIOD_OPTIONS="${PUBLIC_IP} ${INTERFACE}" +REDIRECTORD_OPTIONS="${PUBLIC_IP} ${DOMAIN}" diff --git a/debian/autoradio.radiod.service b/debian/autoradio.radiod.service new file mode 100644 index 00000000..0a3ce934 --- /dev/null +++ b/debian/autoradio.radiod.service @@ -0,0 +1,13 @@ +[Unit] +Description=autoradio Icecast supervisor +After=etcd.service +Wants=etcd.service + +[Service] +User=icecast2 +EnvironmentFile=-/etc/default/autoradio +ExecStart=/usr/sbin/radiod ${RADIOD_OPTIONS} +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/debian/autoradio.redirectord.service b/debian/autoradio.redirectord.service new file mode 100644 index 00000000..9cad2b54 --- /dev/null +++ b/debian/autoradio.redirectord.service @@ -0,0 +1,13 @@ +[Unit] +Description=autoradio front-end +After=etcd.service +Wants=etcd.service + +[Service] +User=nobody +EnvironmentFile=-/etc/default/autoradio +ExecStart=/usr/sbin/redirectord ${REDIRECTORD_OPTIONS} +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/debian/control b/debian/control index 57ff15ea..de72cdb3 100644 --- a/debian/control +++ b/debian/control @@ -2,14 +2,14 @@ Source: autoradio Section: net Priority: extra Maintainer: ale <ale@incal.net> -Build-Depends: debhelper (>= 8.0.0) +Build-Depends: debhelper (>= 8.0.0), dh-systemd Standards-Version: 3.9.4 Homepage: https://git.autistici.org/ale/autoradio Package: autoradio Architecture: any Depends: icecast2, liquidsoap, liquidsoap-plugin-lame, liquidsoap-plugin-icecast, - liquidsoap-plugin-mad, liquidsoap-plugin-vorbis, runit, libcap2-bin, + liquidsoap-plugin-mad, liquidsoap-plugin-vorbis, libcap2-bin, ${shlibs:Depends}, ${misc:Depends} Description: Icecast clustering software. Runs icecast2 in a cluster controlled by etcd. diff --git a/debian/rules b/debian/rules index 35214820..51d4ac40 100755 --- a/debian/rules +++ b/debian/rules @@ -19,23 +19,24 @@ export DH_OPTIONS GOPKG = git.autistici.org/ale/autoradio DESTDIR = $(CURDIR)/debian/autoradio -SVCDIR = $(DESTDIR)/etc/svc %: - dh $@ + dh $@ --with systemd override_dh_install: # Build the binary + (mkdir -p $(CURDIR)/build/src/$(dir $(GOPKG)) && \ + ln -s $(CURDIR) $(CURDIR)/build/src/$(GOPKG) && \ + cd $(CURDIR)/build/src/$(GOPKG) && \ + env GOPATH=$(CURDIR)/build PATH=$$PATH:/usr/local/bin go install -v ./...) install -m 755 -o root -g root -d $(DESTDIR)/usr/bin - (tmpdir=$$(mktemp -d) ; \ - export GOPATH=$$tmpdir ; unset GOBIN ; \ - mkdir -p $$tmpdir/src/$(dir $(GOPKG)) ; \ - ln -s $(CURDIR) $$tmpdir/src/$(GOPKG) ; \ - cd $$tmpdir/src/$(GOPKG) && go install -v ./... && \ - for bin in radiod redirectord radioctl ; do \ - install -m 755 -o root -g root $$tmpdir/bin/$$bin $(DESTDIR)/usr/bin/$$bin ; \ - done ; \ - rm -fr $$tmpdir) + (for bin in radioctl radiobench ; do \ + install -m 755 -o root -g root $(CURDIR)/build/bin/$$bin $(DESTDIR)/usr/bin/$$bin ; \ + done) + install -m 755 -o root -g root -d $(DESTDIR)/usr/sbin + (for bin in redirectord radiod ; do \ + install -m 755 -o root -g root $(CURDIR)/build/bin/$$bin $(DESTDIR)/usr/sbin/$$bin ; \ + done) # Install the static files and templates for the HTTP dashboard. install -d -m 755 -o root -g root $(DESTDIR)/usr/share/autoradio @@ -48,21 +49,15 @@ override_dh_install: install -o root -g root -m 644 $$f $(DESTDIR)/usr/share/autoradio/htdocs/templates/ ; \ done) - # Install runit service runners. - install -d -m 755 -o root -g root $(SVCDIR) - install -m 644 -o root -g root $(CURDIR)/debian/services/lib.sh \ - $(DESTDIR)/usr/share/autoradio/lib.sh - (for f in radiod redirectord ; do \ - install -d -o root -g root $(SVCDIR)/$$f ; \ - install -d -o root -g root $(SVCDIR)/$$f/log ; \ - install -m 755 -o root -g root $(CURDIR)/debian/services/$$f \ - $(SVCDIR)/$$f/run ; \ - echo '#!/bin/sh\nexec chpst -u log svlogd -tt /var/log/'$$f > \ - $(SVCDIR)/$$f/log/run ; \ - chmod 0755 $(SVCDIR)/$$f/log/run ; \ - done) - # Icecast2 status XSL template. install -d -m 755 -o root -g root $(DESTDIR)/usr/share/icecast2/web install -m 644 -o root -g root $(CURDIR)/debian/status.xsl \ $(DESTDIR)/usr/share/icecast2/web/status-autoradio.xsl + +override_dh_clean: + -rm -fr build + dh_clean + +override_dh_systemd_enable: + dh_systemd_enable --name=radiod + dh_systemd_enable --name=redirectord diff --git a/debian/services/lib.sh b/debian/services/lib.sh deleted file mode 100644 index f991af97..00000000 --- a/debian/services/lib.sh +++ /dev/null @@ -1,54 +0,0 @@ -# Common functions for the 'autoradio' startup scripts. - -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:$PATH -export PATH - -test -e /etc/default/autoradio && . /etc/default/autoradio - -if [ -z "${DOMAIN}" ]; then - echo "You must set DOMAIN in /etc/default/autoradio!" 1>&2 - exit 1 -fi - -resolveall() { - local name="$1" - local port="$2" - getent hosts ${name} | awk "{print \$1 \":${port}\"}" -} - -commaseplist() { - local out= - for arg in "$@" ; do - out="${out}${out:+,}${arg}" - done - echo "${out}" -} - -set_public_ip() { - # Try to guess the public IP of this host if unset, resolving the - # fully-qualified host name. - if [ -z "${PUBLIC_IP}" ]; then - PUBLIC_IP=$(getent hosts $(hostname -f) | awk '{print $1}' | head -1) - fi - if [ -z "${PUBLIC_IP}" ]; then - PUBLIC_IP=127.0.0.1 - fi -} - -set_interface() { - # Try to guess the network interface for PUBLIC_IP. - if [ -z "${INTERFACE}" ]; then - INTERFACE=$(/sbin/ip -o addr show to ${PUBLIC_IP} | awk '{print $2}') - fi - if [ -z "${INTERFACE}" ]; then - echo "Warning: could not autodetect network interface for ${PUBLIC_IP}" 1>&2 - INTERFACE=eth0 - fi -} - -set_etcd_params() { - local default_etcd_server="etcd.${DOMAIN}" - ETCD_SERVER="${ETCD_SERVER:-${default_etcd_server}}" - local server_ips=$(commaseplist localhost:2379 $(resolveall ${ETCD_SERVER} 2379)) - ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-servers=${server_ips}" -} diff --git a/debian/services/radiod b/debian/services/radiod deleted file mode 100755 index 8ad92cc9..00000000 --- a/debian/services/radiod +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -. /usr/share/autoradio/lib.sh - -set_public_ip -set_interface -set_etcd_params - -exec chpst -u icecast2 \ - radiod --ip=${PUBLIC_IP} --interface=${INTERFACE} ${ETCD_OPTIONS} ${RADIOD_OPTIONS} \ - 2>&1 diff --git a/debian/services/redirectord b/debian/services/redirectord deleted file mode 100755 index 9f6fd220..00000000 --- a/debian/services/redirectord +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -. /usr/share/autoradio/lib.sh - -set_public_ip -set_etcd_params - -exec chpst -u nobody \ - redirectord --ip=${PUBLIC_IP} --domain=${DOMAIN} \ - ${ETCD_OPTIONS} ${REDIRECTORD_OPTIONS} \ - 2>&1 -- GitLab