Merge pull request #7 from icedream/develop

Version 0.3.
master
Carl Kittelberger 2015-11-05 20:01:25 +01:00
commit cd4e27005c
8 changed files with 103 additions and 84 deletions

View File

@ -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

View File

@ -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" ]

View File

@ -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 <url>` - Plays a URL
- `stop` - Stops playback
- `changenick <nickname>` - Changes the bot's nickname
- `changenick <nickname>` - Changes the bot's nickname.
- `clear` or `empty` - Empties the current playlist.
- `current` - Shows the currently playing track in the chat.
- `enqueue <url>` or `add <url>` or `append <url>` - 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 <url>` - 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 <value>` - 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?

30
etc/pulse/default.pa Normal file
View File

@ -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

View File

@ -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

View File

@ -1,2 +0,0 @@
#!/bin/sh
exec dbus-daemon --nofork --system

View File

@ -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

39
setup.sh Normal file
View File

@ -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/*