From b094aa0d2ef2143521a53c3986d86c3fb59c5d22 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 7 Mar 2014 19:19:53 -0800 Subject: [PATCH] irker: Add irker, a simple IRC multiplexer daemon Send messages to an IRC channel from Bash (or anything else that can send JSON over UDP or TCP). --- README.md | 1 + build.sh | 1 + irker/Dockerfile.template | 57 +++++++++++++++++++++++++++++++++++++++ irker/README.md | 28 +++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 irker/Dockerfile.template create mode 100644 irker/README.md diff --git a/README.md b/README.md index 4bcebf3..fb83730 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The dependency graph is: | `-- package-cache (adds a package-cache proxy) |-- gentoo-node (adds Node and npm) | `-- hubot (adds hubot with an IRC adapter) + |-- irker (adds irker, and spawns irkerd by default) |-- memcached (adds Memcached) |-- nginx (adds Nginx) | |-- nginx-proxy (SSL/TLS proxying via SNI) diff --git a/build.sh b/build.sh index 8d4f66b..5dc238e 100755 --- a/build.sh +++ b/build.sh @@ -53,6 +53,7 @@ REPOS="${REPOS:- docker-registry elasticsearch hubot + irker kibana kibana-azure memcached diff --git a/irker/Dockerfile.template b/irker/Dockerfile.template new file mode 100644 index 0000000..00f671d --- /dev/null +++ b/irker/Dockerfile.template @@ -0,0 +1,57 @@ +# Copyright (C) 2014 W. Trevor King +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * 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. +# +# 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 COPYRIGHT HOLDER 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. + +FROM ${NAMESPACE}/gentoo-syslog:${TAG} +MAINTAINER ${MAINTAINER} +#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"] + +# required by irker (argument) +RUN echo '=net-irc/irker-1.20 ~amd64' >> /etc/portage/package.accept_keywords + +# Work around https://bugs.gentoo.org/show_bug.cgi?id=503350 +# +# net-irc/irker-1.20 depends on dev-python/irc, but that dependency +# was actually removed in irker v1.20 [1]. Still, we need to keep +# this workaround until a new ebuild drops that dependency [2,3]. +# +# [1]: https://gitorious.org/irker/irker/commit/79a38e602ba429fef7d5842d3390c51e631795f6 +# [2]: https://bugs.gentoo.org/show_bug.cgi?id=438240 +# [3]: https://bugs.gentoo.org/show_bug.cgi?id=491808#c0 +RUN echo '=dev-python/irc-8.5.4 ~amd64' >> /etc/portage/package.accept_keywords +RUN emerge -v dev-python/setuptools + +RUN emerge -v net-irc/irker + +RUN emerge -v dev-vcs/git +RUN git clone --branch ssl-tls --single-branch --depth 1 git://tremily.us/irker.git +RUN cp -f irker/irkerd /usr/bin/irkerd + +RUN eselect news read new +RUN sed -i 's/\(start-stop-daemon --start.*--quiet\) \(--exec $command\)$/\1 --pidfile ${pidfile} --make-pidfile --background \2 -- $command_args/' /etc/init.d/irkerd +RUN sed -i 's/\(start-stop-daemon --stop --quiet\)/\1 --pidfile ${pidfile}/' /etc/init.d/irkerd +RUN sed -i 's/#IRKERD_OPTS=""/IRKERD_OPTS="--host 0.0.0.0 --syslog"/' /etc/conf.d/irkerd +RUN rc-update add irkerd default + +CMD rc default && tail -F /var/log/messages +EXPOSE 6659 diff --git a/irker/README.md b/irker/README.md new file mode 100644 index 0000000..675d9fc --- /dev/null +++ b/irker/README.md @@ -0,0 +1,28 @@ +Run this [irker][] image with: + + $ docker run -d --name irker-0 --hostname irker.example.net \ + > -p 6659:6659 -p 6659:6659/udp wking/irker + +which fires up an [irkerd][] daemon. Then send in your packets as +single-line JSON objects. You can use [Bash][] [redirection][] to do +that from the command line: + + $ docker inspect irker-0 | grep IPAddress + "IPAddress": "10.0.0.4", + $ echo '{"to": "irc://chat.freenode.net/some-channel", "privmsg": "Hello, world!"}' >/dev/tls/10.0.0.4/6659 + +Opening both TCP and UDP ports has been [supported][tcp-and-udp-pr] +[since Docker 0.7.1][tcp-and-udp-bug]. + +The current irkerd trunk doesn't support SSL/TLS for server +connections, so I pull in my [updates][ssl-tls] and clobber the +installed `/usr/bin/irkerd`. I also patch up the stock irkerd init +script. + +[irker]: http://www.catb.org/~esr/irker/ +[irkerd]: http://www.catb.org/~esr/irker/irkerd.html +[tcp-and-udp-pr]: https://github.com/dotcloud/docker/pull/1177 +[tcp-and-udp-bug]: https://github.com/dotcloud/docker/issues/3149 +[Bash]: https://www.gnu.org/software/bash/ +[redirection]: https://www.gnu.org/software/bash/manual/html_node/Redirections.html +[ssl-tls]: http://git.tremily.us/?p=irker.git;a=shortlog;h=refs/heads/ssl-tls -- 2.26.2