diff --git a/debian/README b/debian/README new file mode 100644 index 0000000000000000000000000000000000000000..35e66abb31c814b0875073bec3142ff0a100f8cf --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package radioai +---------------------------- + +Icecast clustering software. + + -- ale <ale@incal.net> Thu, 07 Nov 2013 09:00:44 +0000 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000000000000000000000000000000..a707f98eacf8c90d4034fbbafd2cb9b3ded7e744 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +radioai (0.1) unstable; urgency=low + + * Initial Release. + + -- ale <ale@incal.net> Thu, 07 Nov 2013 09:00:44 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000000000000000000000000000000000000..45a4fb75db864000d01701c0f7a51864bd4daabf --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000000000000000000000000000000..7a2ee1e4156a0059bae141409083bc2d2d373cc6 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: radioai +Section: net +Priority: extra +Maintainer: ale <ale@incal.net> +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.4 +Homepage: https://git.autistici.org/ale/radioai + +Package: radioai +Architecture: any +Depends: icecast2, runit, libcap2-bin, ${shlibs:Depends}, ${misc:Depends} +Description: Icecast clustering software. + Runs icecast2 in a cluster controlled by etcd. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000000000000000000000000000000000..ab450ff8df052d288d21445bd08994740df92700 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,42 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: radioai +Source: <url://example.com> + +Files: * +Copyright: <years> <put author's name and email here> + <years> <likewise for another author> +License: BSD-3-Clause + +Files: debian/* +Copyright: 2013 ale <ale@incal.net> +License: BSD-3-Clause + +License: BSD-3-Clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid to pick license terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000000000000000000000000000000000000..5992a913af0643bde4f299b2955033b448355268 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,64 @@ +#!/bin/sh +# postinst script for radioai +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * <postinst> `configure' <most-recently-configured-version> +# * <old-postinst> `abort-upgrade' <new version> +# * <conflictor's-postinst> `abort-remove' `in-favour' <package> +# <new-version> +# * <postinst> `abort-remove' +# * <deconfigured's-postinst> `abort-deconfigure' `in-favour' +# <failed-install-package> <version> `removing' +# <conflicting-package> <version> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +create_users() { + if ! getent passwd log 2>/dev/null ; then + adduser --system --home /var/log --no-create-home --group log + fi +} + +create_log_dir() { + logdir=/var/log/radioai + for d in radiod redirectord ; do + mkdir -p ${logdir}/${d} + chown log:log ${logdir}/${d} + done +} + +activate_services() { + for svc in $@ ; do + test -e /etc/service/$svc \ + || ln -s /etc/radioai/svc/$svc /etc/service/$svc + done +} + + +case "$1" in + configure) + create_users + create_log_dir + activate_services radiod redirectord + ;; + + 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/radioai.default b/debian/radioai.default new file mode 100644 index 0000000000000000000000000000000000000000..de7baa6f90f5cd5f0478574f13181708d3073d04 --- /dev/null +++ b/debian/radioai.default @@ -0,0 +1,20 @@ +# Defaults for radioai initscript +# sourced by /etc/init.d/radioai +# installed at /etc/default/radioai by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Set your base domain name here. +DOMAIN="" + +# Set your public IP if necessary (otherwise we'll try to resolve +# if your fully-qualified hostname). +#PUBLIC_IP="" + +# Set the etcd servers to connect to (default: etcd.$DOMAIN). +#ETCD_SERVER="" + +# Additional options that are passed to the daemons. +DAEMON_OPTS="" diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000000000000000000000000000000..926be2ac5a269a115f4a8a072a1a5bea37ba75e0 --- /dev/null +++ b/debian/rules @@ -0,0 +1,53 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. +# +# Modified to make a template file for a multi-binary package with separated +# build-arch and build-indep targets by Bill Allombert 2001 + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +GOPKG = git.autistici.org/ale/radioai + +DESTDIR = $(CURDIR)/debian/radioai +SVCDIR = $(DESTDIR)/etc/radioai/svc + +%: + dh $@ + +override_dh_install: + 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 && \ + go get -d -v ./$(GOPKG)/... && go install -v ./$(GOPKG)/... && \ + 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) + + install -d -m 755 -o root -g root $(SVCDIR) + install -d -m 755 -o root -g root $(DESTDIR)/usr/share/radioai + install -m 644 -o root -g root debian/services/lib.sh \ + $(DESTDIR)/usr/share/radioai/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 debian/services/$$f \ + $(SVCDIR)/$$f/run ; \ + chmod 0755 $(SVCDIR)/$$f/log/run ; \ + echo -e '#!/bin/sh\nexec chpst -u log svlogd -tt /var/log/radioai/'$$f > \ + $(SVCDIR)/$$f/log/run ; \ + done) + diff --git a/debian/services/lib.sh b/debian/services/lib.sh new file mode 100644 index 0000000000000000000000000000000000000000..a72f67fc266aa7f609b1c4e0a9921ae009218398 --- /dev/null +++ b/debian/services/lib.sh @@ -0,0 +1,28 @@ +# Common functions for the 'radioai' startup scripts. + +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:$PATH +export PATH + +test -e /etc/default/radioai && . /etc/default/radioai + +if [ -z "${DOMAIN}" ]; then + echo "You must set DOMAIN in /etc/default/radioai!" 1>&2 + exit 1 +fi + +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_etcd_params() { + local default_etcd_server="etcd.${DOMAIN}" + ETCD_SERVER="${ETCD_SERVER:-${default_etcd_server}}" + ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-server=${ETCD_SERVER}" +} diff --git a/debian/services/radiod b/debian/services/radiod new file mode 100755 index 0000000000000000000000000000000000000000..848979b324af4243676072184b629e06c0028bb1 --- /dev/null +++ b/debian/services/radiod @@ -0,0 +1,9 @@ +#!/bin/sh + +. /usr/share/radiod/lib.sh + +set_public_ip +set_etcd_params + +exec chpst -u icecast2 \ + radiod --ip=${PUBLIC_IP} ${ETCD_OPTIONS} ${DAEMON_OPTIONS} diff --git a/debian/services/redirectord b/debian/services/redirectord new file mode 100755 index 0000000000000000000000000000000000000000..ceac67a51b2f199191e51a410d008fb4a48e9420 --- /dev/null +++ b/debian/services/redirectord @@ -0,0 +1,10 @@ +#!/bin/sh + +. /usr/share/radiod/lib.sh + +set_public_ip +set_etcd_params + +exec setcap cap_net_bind_service=+ep \ + chpst -u nobody \ + redirectord --ip=${PUBLIC_IP} ${ETCD_OPTIONS} ${DAEMON_OPTIONS} diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000000000000000000000000000000000..89ae9db8f88b823b6a7eabf55e203658739da122 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native)