In this tutorial/howto we install the :ref:`start-label` into a users home directory. No system services are used.
.. seealso:: - :ref:`compatibility-label` - :ref:`howtorunthebot-label` - :ref:`configexplain-label`
This tutorial works well using copy and paste if you want one bot only. If you want more bots, read the note boxes and warning boxes :)
After 10 to 20 minutes it should be finished, depending on your servers internet connection.
This will be the directory structure when this howto is completed:
/home/botmaster/ ├── mpd1 │ ├── playlists │ ├── mpd1.log │ ├── mpd.conf │ ├── mpd.fifo │ ├── pid │ ├── state │ ├── sticker.sql │ └── tag_cache ├── (optional) more mpd directories ... mpd2, mpd3, etc. ├── logs ├── music │ └── downloadedfromyt │ └── downloadedfromsc │ └── [...] ├── src │ └── certs │ └── nameofyourbot_cert │ └── [...] │ └── mumble-ruby │ └── mumble-ruby-pluginbot │ │ └── scripts │ │ └── mumblerubypluginbot.service │ │ └── overwrite_conf.rb │ │ └── manage.sh │ │ └── updater.sh │ │ └── [...] │ └── bot1_conf.yml │ └── (optional) more bot<number>_conf.yml │ └── [...] ├── temp │ └── youtubeplugin │ └── bandcampplugin │ └── [...] [...]
Install the following dependencies as root or via sudo:
pacman -S libyaml opus zlib openssl git mpd mpc tmux automake \ autoconf libogg psmisc util-linux libtool curl base-devel wget aria2
Install the following dependencies as root:
yum install libyaml opus-tools wget aria2 libyaml-devel git opus-devel \ zlib zlib-devel openssl-devel mpd libmpc tmux automake autoconf libtool \ libogg-devel gmp-devel dialog unzip bzip2
Install the following dependencies as root or via sudo (please not that this is one command, copy and paste all four lines):
apt-get install curl libyaml-dev git libopus-dev \ build-essential zlib1g zlib1g-dev libssl-dev mpd mpc tmux \ automake autoconf libtool libogg-dev psmisc util-linux libgmp3-dev \ dialog unzip ca-certificates aria2
The message about no database /var/lib/mpd/tag_cache
can be ignored. The database will be created as soon as you start the MPD server.
As we do not need the system wide MPD it can be disabled. To do this open the file /etc/default/mpd
as root or via sudo and change START_MPD
to false
. At the next system start it will not be started any more.
Note
On newer distributions instead of editing the file you need to disable the MPD service by running the following command as root or with sudo:
systemctl disable mpd systemctl stop mpd
Note
It is crucial that you use the same username as in this tutorial. Otherwise you need to manually adapt most scripts and configuration files to another username.
As root or via sudo:
adduser botmaster
All relevant scripts will run within this user context.
Now it is the time to log in as your new user with:
su - botmaster
All the following steps are done as the user botmaster.
Create a directory for the source code and scripts:
mkdir ~/src
Create a direcotry for log files:
mkdir ~/logs
Create a directory for the certificates:
mkdir ~/src/certs
Create a directory for the music:
mkdir ~/music
Create a directory for the temp files:
mkdir ~/temp
Create the directories for bot 1:
mkdir -p ~/mpd1/playlists
Note
Note that you can use more than one bots with this tutorial. Just create a new directory structure for every additional bot, for example with:
mkdir -p ~/mpd2/playlists
and so on.
We are using RVM (Ruby Version Manager) to install a local version of Ruby instead of using a system wide installed Ruby which may be too old.
First get and add the GPG key of RVM:
curl -sSL https://rvm.io/mpapis.asc | /usr/bin/gpg --import - curl -sSL https://rvm.io/pkuczynski.asc | /usr/bin/gpg --import -
We need at least Ruby 1.9.x, here we use the latest stable version:
curl -L https://get.rvm.io | bash -s stable
Now we need to tell our current shell to use rvm:
source ~/.rvm/scripts/rvm
Disable autolibs so that rvm doesn't ask for root - we already installed all the dependencies earlier:
rvm autolibs disable
The next command should print nothing, if it does print something, login as root and install those:
rvm requirements
Now we install the latest stable version of Ruby:
rvm install ruby --latest
Now setup the environment for Ruby:
rvm --create use @bots
Now we download the source code of Mumble-Ruby and build it:
cd src git clone https://github.com/dafoxia/mumble-ruby.git mumble-ruby cd mumble-ruby rvm use @bots gem build mumble-ruby.gemspec rvm @bots do gem install mumble-ruby-*.gem
Install ruby-mpd so that the bot can control MPD:
rvm @bots do gem install ruby-mpd rvm @bots do gem install crack
For compatibility reasons the bot uses slightly modified versions of CELT which need to be built with the following steps:
cd ~/src git clone https://github.com/dafoxia/celt-ruby.git cd celt-ruby rvm use @bots gem build celt-ruby.gemspec rvm @bots do gem install celt-ruby cd ~/src git clone https://github.com/mumble-voip/celt-0.7.0.git cd celt-0.7.0 ./autogen.sh ./configure --prefix=/home/botmaster/src/celt make make install
Do the following commands:
cd ~/src git clone https://github.com/dafoxia/opus-ruby.git cd opus-ruby rvm use @bots gem build opus-ruby.gemspec rvm @bots do gem install opus-ruby
Do the following commands:
cd ~/src git clone https://github.com/MusicGenerator/mumble-ruby-pluginbot.git cd mumble-ruby-pluginbot
We need a configuration file for the manage script:
cp templates/manage.conf ~/src/manage.conf
Now we create a copy of the config that we will use:
cp templates/override_config.yml ~/src/bot1_conf.yml
This approach has the advantage that this config file contains only the variables you want to change. All the other variables not set in your bot1_conf.yml are used from the ~/src/mumble-ruby-pluginbot/config/config.yml file and all plugins/*.yml files. See :ref:`here <label-configexplain_override_and_main_config>` for details.
You should now edit the bots configuration file named "bot1_conf.yml" with your favorite editor:
nano ~/src/bot1_conf.yml
... and adapt at least the following settings to your needs:
- mumble -> host
- mumble -> port
- mumble -> username
- mumble -> password
- Note: This password is optional only and not needed if you want to register the bot as an admin on your server.
- mumble -> channel
- Note: This channel name is the one your bots tries to enter when getting a .gotobed
- mumble -> bitrate
- Note: If you set a higher bandwidth than your server can handle the bot automatically reduces its bandwidth to fit the servers needs.
The rest of the configuration file should be fine.
Note
For every additional bot you need to copy the original config file and edit it, for example for bot 2 do:
cd ~/src/mumble-ruby-pluginbot cp templates/override_config.yml ~/src/bot2_conf.yml
Now edit ~/src/bot2_conf.yml and change at least the following variables:
- main -> logfile to "/home/botmaster/logs/bot2.log", and so forth
- main -> fifo to "/home/botmaster/mpd2/mpd.fifo", and so forth
- mumble -> name to "anything different then for bot1", and so forth
- plugin -> mpd -> port to 7702, and so forth
Copy the configuration file for your local MPD:
cp ~/src/mumble-ruby-pluginbot/templates/mpd.conf ~/mpd1/mpd.conf
Note
For every additional bot you must increase the number of ~/mpd1/... by one. For a second bot use:
cp ~/src/mumble-ruby-pluginbot/templates/mpd.conf ~/mpd2/mpd.conf
Then open the downloaded mpd.conf
file and substitude every occurence of mpd1
by mpd2
. Also increase the port from 7701 to 7702, 7703, etc.
Note
For experts only: Explanations about the configuration file and additional settings you may want to have...
You can see the configuration file at here..
Instead of the default sample rate of 44100 this config uses 48000 which is the sample rate Mumble clients use. And we need a mono signal.
The mixer type is set to software so that the volume in MPD can be changed without the need of a real soundcard.
You can enable volume normalization by adding the following line to the mpd config file:
volume_normalization "yes"
Change into the mumble-ruby-pluginbot directory:
cd ~/src/mumble-ruby-pluginbot
The Bash script named manage.sh
in the scripts directory is used to start all your bots and your MPD instance(s).
Make it executable:
chmod u+x ~/src/mumble-ruby-pluginbot/scripts/manage.sh
Also make the update script executable:
chmod u+x ~/src/mumble-ruby-pluginbot/scripts/updater.sh
Note
If you created more than one bot in this tutorial open the file ~/src/manage.conf and add every additional bot (its number) to the value of BOTS_ENABLED. For example if you created two bots, set the value to "1 2". When you created three bots set it to "1 2 3".
Without modification the scripts starts only bot 1, for every additional bot modify ~/src/manage.conf.
You don't want to rely on the distributions version of an old youtube-dl so you must setup an own.
As root or with sudo install:
pacman -S imagemagick ffmpeg python
As root install:
yum install ImageMagick python ffmpeg
Only on Debian/Ubuntu based distributions: Install the dependencies (if ffmpeg is available for your distribution)
First install as root or via sudo the following system packages:
apt-get install imagemagick ffmpeg python
Only on Debian/Ubuntu based distributions (OPTIONAL): Install the dependencies (if ffmpeg IS NOT available for your distribution)
On some distributions the package ffmpeg was replaced by libav-tools; install this if ffmpeg is not available.
Install as root or via sudo the following system packages:
apt-get install imagemagick libav-tools python
Also create the symlink so that the plugin can find it:
ln -s /usr/bin/avconv /usr/bin/ffmpeg
If not already logged in as botmaster, then do:
su - botmaster
The youtube plugin needs youtube-dl; download it and make it executable:
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o ~/src/youtube-dl chmod u+x ~/src/youtube-dl
You almost finished; now you can run your bot(s):
~/src/mumble-ruby-pluginbot/scripts/manage.sh start
When the bot(s) appear on your server, register it/them and start working with it/them. Try .help
as the first command.
.. seealso:: If the bot does not connect refer to :ref:`knownproblems-label`.
Add the following lines to /etc/rc.local
before the exit...
line to start your bot(s) when your system starts:
su - botmaster -c "/home/botmaster/src/mumble-ruby-pluginbot/scripts/manage.sh start" &
The bot will start automatically on the next system start.
Run the following command as root:
cp /home/botmaster/src/mumble-ruby-pluginbot/templates/mumblerubypluginbot.service /etc/systemd/system/ systemctl enable mumblerubypluginbot
The bot will start automatically on the next reboot.
Thats it, you are done :)
To restart your bot(s) run:
~/src/mumble-ruby-pluginbot/scripts/manage.sh restart
To stop your bot(s) run:
~/src/mumble-ruby-pluginbot/scripts/manage.sh stop
To watch log files in real time run:
~/src/mumble-ruby-pluginbot/scripts/manage.sh log
To get the current status of your bot(s) run:
~/src/mumble-ruby-pluginbot/scripts/manage.sh status
.. seealso:: See :ref:`configexplain-label`.
.. seealso:: See :ref:`knownproblems-label`.