-
Notifications
You must be signed in to change notification settings - Fork 0
Guide for Ubuntu

If you are new to using Ubuntu, there is a guide on Digital Ocean's community tutorial site that will provide information on how to setup and configure the operating system.
The bot requires other software installed on your Ubuntu machine. Run these commands in your terminal window.
sudo apt-get install build-essential unzip -y
sudo apt-get install software-properties-common -yRun the following commands on Ubuntu 14.04 only
sudo add-apt-repository ppa:deadsnakes -y
sudo add-apt-repository ppa:mc3man/trusty-media -y
sudo add-apt-repository ppa:chris-lea/libsodium -y
sudo apt-get update -y
sudo apt-get install git python python3.5-dev ffmpeg libopus-dev libffi-dev libsodium-dev -y
sudo apt-get upgrade -yRun the following commands on Ubuntu 16.04 or higher only
sudo add-apt-repository ppa:mc3man/xerus-media -y
sudo apt-get update -y
sudo apt-get install git ffmpeg libopus-dev libffi-dev libsodium-dev python3-pip -y
sudo apt-get upgrade -yRun the following commands to download MusicBot. This will place it in a new folder called MusicBot, which we will immediately enter.
git clone https://github.com/mdegouw/MusicBot.git MusicBot -b master
cd MusicBot
At this point you should create a bot account and add it to your server.
The folder we're in contains all of the bots files. Do not delete or rename any files/folders. We now need to configure the bot. The following paragraph should be done using an FTP client connected to your Ubuntu machine. If you want to edit the config file from Ubuntu, see this AskUbuntu answer.
Inside the bot's folder is another folder called config. Open it, and then open the example_options.ini file. This is the file containing the bot's settings. All options are explained in the file. Make sure you save the file as options.ini after editing and upload it back to the Ubuntu machine. If you need help, read the configuration page.
Firstly, ensure pip is up to date.
# Ubuntu 14.04(.*) LTS
python3.5 -m pip install --upgrade pip
# Ubuntu 16.04 LTS or higher
python3 -m pip install --upgrade pipBefore starting your bot, update the Python dependencies using pip. To do that, use this command (you may have to run it using sudo):
# Ubuntu 14.04(.*) LTS
python3.5 -m pip install -U -r requirements.txt
# Ubuntu 16.04 LTS or higher
python3 -m pip install -U -r requirements.txtYou can test that your bot works by running this command:
# Ubuntu 14.04(.*) LTS
python3.5 run.py
# Ubuntu 16.04 LTS or higher
python3 run.pyIf you close your SSH session/console, the bot will stop running.
If you're already running the bot, press CTRL + C a few times to stop it from running and get you back to being able to use console commands.
There are a number of options that can allow you to run the bot permanently, so that it continues even if you are not connected to your Ubuntu machine through an SSH client.
Run this command to make a tmux console and then run the bot:
tmux new -s bot
# Ubuntu 14.04(.*) LTS
python3.5 run.py
# Ubuntu 16.04 LTS or higher
python3 run.pyNow that the bot is running, press CTRL+B then d separately to 'detach' from the tmux session. If you ever want to have a look at the bot's console logs, SSH back into the machine and run tmux a.
Run this command to make a screen console and run the bot:
screen -S bot
# Ubuntu 14.04(.*) LTS
python3.5 run.py
# Ubuntu 16.04 LTS or higher
python3 run.pyNow that the bot is running, press Ctrl+A then d separately to 'detach' from the screen. If you ever want to have a look at the bot's console logs, SSH back into the machine and run screen -r bot.
Run these commands to install node.js and pm2, then start the Python script using it:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install pm2@latest -g
# Ubuntu 14.04(.*) LTS
pm2 start run.py -n "bot" --interpreter=python3.5
# Ubuntu 16.04 LTS or higher
pm2 start run.py -n "bot" --interpreter=python3To manage and review the status of the bot, type pm2 status. To view the logs/console for the bot, type pm2 logs. pm2 will restart the script if it breaks, and show you the uptime among other details on the status page. More information about how to use pm2 can be found here: https://www.npmjs.com/package/pm2