diff --git a/DOCKER_HUB_NETWORK_FAILS.txt b/DOCKER_HUB_NETWORK_FAILS.txt new file mode 100644 index 0000000..558f553 --- /dev/null +++ b/DOCKER_HUB_NETWORK_FAILS.txt @@ -0,0 +1,4 @@ +# This text file is just a counter for how often Docker Hub failed to build our image for TS3Bot due to networking issues since Oct 19, 2015. +# This became necessary to retrigger the build just for the current branch instead of having to trigger the build from Docker Hub for ALL branches instead. +# Let's hope this counter will never reach 100... +2 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d3a791f..99ee67c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,60 +1,21 @@ -FROM phusion/passenger-nodejs:0.9.17 +FROM node:4.2 -# prepare APT with only the repositories we want -RUN rm /etc/apt/sources.list.d/* &&\ - add-apt-repository ppa:mc3man/trusty-media -y &&\ - DEBIAN_FRONTEND=noninteractive curl -sL https://deb.nodesource.com/setup_4.x | bash - &&\ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - nodejs \ - blackbox xvfb xdotool \ - pulseaudio pulseaudio-utils \ - dbus \ - python python-minimal python-pkg-resources rtmpdump ffmpeg \ - vlc vlc-plugin-pulse +ENV TS3CLIENT_VERSION 3.0.18.2 +ENV TS3BOT_COMMIT 7160acee75e8f9436e1a636d4a37cca6836f857c -# initialize DBus -RUN mkdir -p /var/run/dbus && \ - chown messagebus:messagebus /var/run/dbus && \ - dbus-uuidgen --ensure +# Add "app" user +RUN mkdir -p /tmp/empty &&\ + groupadd -g 9999 app &&\ + useradd -d /home/app -l -N -g app -m -k /tmp/empty -u 9999 app &&\ + rmdir /tmp/empty -# configure gui user -RUN mkdir -p /config &&\ - ln -sf /config ~app/.ts3bot +ADD setup.sh / +RUN sh /setup.sh -# install teamspeak3 -# Original comment that used to be here: temporary non-interactive teamspeak3 install hack, remove before publishing!! -# In fact, it would be nice if we had some lazy handling code for this that just requires the user to provide a "--agree-with-license" once. -ENV TS3CLIENT_VERSION 3.0.18.1 -ADD http://dl.4players.de/ts/releases/${TS3CLIENT_VERSION}/TeamSpeak3-Client-linux_amd64-${TS3CLIENT_VERSION}.run /home/app/ts3client.run -WORKDIR /home/app -RUN chmod +x ./ts3client.run &&\ - sed -i 's/^MS_PrintLicense$/#MS_PrintLicense/g' ./ts3client.run &&\ - ./ts3client.run --quiet --target ts3client &&\ - rm ./ts3client.run -USER root - -# install the ts3bot-control app properly -ENV TS3BOT_COMMIT 6d49bdfdaa1232b66df5ff70e884f137544a8a97 -ADD https://github.com/icedream/ts3bot-control/archive/${TS3BOT_COMMIT}.tar.gz /home/app/ts3bot-control.tgz -WORKDIR /home/app -RUN tar xvf ts3bot-control.tgz &&\ - rm ts3bot-control.tgz &&\ - mv ts3bot-control* ts3bot -WORKDIR /home/app/ts3bot -RUN npm install - -# install youtube-dl -ADD https://yt-dl.org/latest/youtube-dl /usr/local/bin/youtube-dl -RUN chmod a+rx /usr/local/bin/youtube-dl - -# initialize other configuration for daemons +# Copy over configuration for other daemons COPY etc/ /etc -# clean up apt -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -VOLUME [ "/home/app/ts3client" ] - +# Startup configuration WORKDIR /home/app -ENTRYPOINT [ "/sbin/my_init" ] +USER app +CMD [ "ts3bot", "--ts3-install-path=/home/app/ts3client" ] diff --git a/README.md b/README.md index 53eb3ff..89da6e5 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,27 @@ This is the Docker image that contains everything necessary to run Icedream's TS ## Supported features -- Thanks to youtube-dl support for YouTube, SoundCloud, hundreds of other video portals and direct livestreams +- Thanks to youtube-dl support for YouTube, SoundCloud, hundreds of other media portals and direct livestreams +- Change the volume on the bot on the fly +- Playlisting system (you can currently enqueue tracks, skip tracks and loop them) - Takes commands from both channel and private messages - Can change nickname on the fly ## Supported commands -- `play ` - Plays a URL -- `stop` - Stops playback -- `changenick ` - Changes the bot's nickname +- `changenick ` - Changes the bot's nickname. +- `clear` or `empty` - Empties the current playlist. +- `current` - Shows the currently playing track in the chat. +- `enqueue ` or `add ` or `append ` - Adds a URL to the playlist. +- `loop on` or `loop off` - Enables or disables playlist looping. +- `next` - Jumps to the next item in the playlist. +- `pause` - Pause playback of the current track. +- `play` - Resumes playback of the current track. +- `play ` - Plays a URL. +- `prev` or `previous` - Jumps to the previous item in the playlist. +- `stop` - Stops playback immediately. +- `stop-after` - Stops playback after the current item is done playing. +- `vol ` - Changes the playback volume, value can be between 0 (for 0%) and 200 (for 200%). Default at startup is 50 (50%). ## How to run this? diff --git a/etc/pulse/default.pa b/etc/pulse/default.pa new file mode 100644 index 0000000..02341e5 --- /dev/null +++ b/etc/pulse/default.pa @@ -0,0 +1,30 @@ +.fail + +# Set tsched=0 here if you experience glitchy playback. This will +# revert back to interrupt-based scheduling and should fix it. + +# Audio sinks +load-module module-rescue-streams +load-module module-always-sink +load-module module-null-sink sink_name="TS3Bot" sink_properties=device.description="TS3Bot" + +# Restore +load-module module-device-restore +load-module module-stream-restore + +# Accept clients -- very important +load-module module-native-protocol-unix + +.ifexists module-x11-publish.so + # Publish to X11 so the clients know how to connect to Pulse. Will + # clear itself on unload. + load-module module-x11-publish +.endif + +.nofail + +# Suspend on idle +load-module module-suspend-on-idle + +# Filters... will we ever need them? +load-module module-filter-apply \ No newline at end of file diff --git a/etc/pulseaudio/default.pa b/etc/pulseaudio/default.pa deleted file mode 100644 index eadc747..0000000 --- a/etc/pulseaudio/default.pa +++ /dev/null @@ -1,22 +0,0 @@ -# Replace the *entire* content of this file with these few lines and -# read the comments - -.fail - # Set tsched=0 here if you experience glitchy playback. This will - # revert back to interrupt-based scheduling and should fix it. - # - # Replace the device= part if you want pulse to use a specific device - # such as "dmix" and "dsnoop" so it doesn't lock an hw: device. - - # Audio sinks - load-module module-null-sink tsched=1 - - # Accept clients -- very important - load-module module-native-protocol-unix - -.nofail -.ifexists module-x11-publish.so - # Publish to X11 so the clients know how to connect to Pulse. Will - # clear itself on unload. - load-module module-x11-publish -.endif \ No newline at end of file diff --git a/etc/service/dbus-daemon/run b/etc/service/dbus-daemon/run deleted file mode 100755 index fb6500b..0000000 --- a/etc/service/dbus-daemon/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec dbus-daemon --nofork --system \ No newline at end of file diff --git a/etc/service/ts3bot/run b/etc/service/ts3bot/run deleted file mode 100755 index 96d8236..0000000 --- a/etc/service/ts3bot/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -export XDG_RUNTIME_DIR="/tmp" -exec /sbin/setuser app nodejs ~app/ts3bot/app.js --ts3-install-path=/home/app/ts3client diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..f11dbb6 --- /dev/null +++ b/setup.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +set -ex + +# For non-interactive install (dpkg) +export INITRD=no +export DEBIAN_FRONTEND=noninteractive + +# Now install all packages we need +apt-get update +apt-get install -y --no-install-recommends \ + ca-certificates \ + blackbox xvfb xdotool \ + pulseaudio pulseaudio-utils \ + cmake python-minimal \ + vlc-nox '^libvlc[0-9]+$' libvlc-dev vlc-plugin-pulse + +# Configure GUI user, we are going to use the pre-setup "app" user for this +mkdir -p /config +ln -sf /config ~app/.ts3bot + +# Install TeamSpeak3. +# Original comment that used to be here: temporary non-interactive teamspeak3 install hack, remove before publishing!! +# In fact, it would be nice if we had some lazy handling code for this that just requires the user to provide a "--agree-with-license" once. +cd ~app +wget http://dl.4players.de/ts/releases/${TS3CLIENT_VERSION}/TeamSpeak3-Client-linux_amd64-${TS3CLIENT_VERSION}.run -Ots3client.run +chmod +x ./ts3client.run +sed -i 's/^MS_PrintLicense$/#MS_PrintLicense/g' ./ts3client.run +./ts3client.run --quiet --target ts3client +rm ./ts3client.run + +# Install TS3Bot via Git +npm_config_wcjs_runtime="node" npm_config_wcjs_runtime_version="$(node --version | tr -d 'v')" \ + npm install --unsafe-perm -g "https://github.com/icedream/ts3bot-control#${TS3BOT_COMMIT}" + +# Clean up APT +apt-get autoremove -y --purge wget cmake cmake-data +apt-get clean +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*