NadekoBot/docs/guides/Linux Guide.md

377 lines
18 KiB
Markdown
Raw Normal View History

2016-10-09 22:44:50 +00:00
##Setting up NadekoBot on Linux
2016-07-24 11:59:30 +00:00
####Setting up NadekoBot on Linux Digital Ocean Droplet
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (and using this link will be supporting Nadeko and will give you **$10 credit**)
2016-07-24 12:04:40 +00:00
####Setting up NadekoBot
Assuming you have followed the link above to setup an account and Droplet with 64bit OS in Digital Ocean and got the `IP address and root password (in email)` to login, its time to get started.
**Go through this whole guide before setting up Nadeko**
2017-02-01 22:22:16 +00:00
####Prerequisites
- Download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
2017-02-01 22:22:16 +00:00
- Download [WinSCP](https://winscp.net/eng/download.php) *(optional)*
2017-02-01 22:22:16 +00:00
####Starting up
2016-07-24 11:59:30 +00:00
- **Open PuTTY.exe** that you downloaded before, and paste or enter your `IP address` and then click **Open**.
2016-05-08 22:02:08 +00:00
If you entered your Droplets IP address correctly, it should show **login as:** in a newly opened window.
2016-07-24 11:59:30 +00:00
- Now for **login as:**, type `root` and hit enter.
- It should then, ask for password, type the `root password` you have received in your **email address registered with Digital Ocean**, then hit Enter.
2016-11-11 11:40:41 +00:00
*as you are running it for the first time, it will most likely to ask you to change your root password, for that, type the "password you received through email", hit Enter, enter a "new password", hit Enter and confirm that "new password" again.*
**SAVE that new password somewhere safe, not just in your mind**. After you've done that, you are ready to write commands.
**NOTE:** Copy the commands, and just paste them using **mouse single right-click.**
2017-02-01 22:22:16 +00:00
####Creating and Inviting bot
- Read here how to [create a DiscordBot application](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#creating-discordbot-application)
- [Visual Invite Guide](http://discord.kongslien.net/guide.html) **(Note: Client ID is your Bot ID)**
- Copy your `Client ID` from your [applications page](https://discordapp.com/developers/applications/me).
- Replace the **12345678** in this link:
`https://discordapp.com/oauth2/authorize?client_id=`12345678`&scope=bot&permissions=66186303`
with your `Client ID`
- The link should now look like this:
`https://discordapp.com/oauth2/authorize?client_id=`**YOUR_CLENT_ID_HERE**`&scope=bot&permissions=66186303`
- Go to the newly created link and pick the server we created, and click `Authorize`
- The bot should have been added to your server.
####Getting NadekoBot
#####Part I
Use the following command to get and run `linuxAIO.sh`
(Remember **Do Not** rename the file **linuxAIO.sh**)
`cd ~ && wget -N https://github.com/Kwoth/NadekoBot-BashScript/raw/master/linuxAIO.sh && bash linuxAIO.sh`
You should see these following options after using the above command:
```
1. Download Dev Build (Latest)
2. Download Stable Build
3. Run Nadeko (Normally)
4. Run Nadeko with Auto Restart (Run Nadeko normally before using this.)
2017-02-08 14:31:22 +00:00
5. Auto-Install Prerequisites (for Ubuntu, Debian and CentOS)
2017-02-01 22:22:16 +00:00
6. Set up credentials.json (if you have downloaded the bot already)
7. To exit
```
2017-02-02 16:45:06 +00:00
#####Part II (Optional)
2017-02-08 14:31:22 +00:00
**If** you are running NadekoBot for the first time on your system and never had any *prerequisites* installed and have Ubuntu, Debian or CentOS, Press `5` and `enter` key, then `y` when you see the following:
2017-02-01 22:22:16 +00:00
```
Welcome to NadekoBot Auto Prerequisites Installer.
Would you like to continue?
```
That will install all the prerequisites your system need to run NadekoBot.
If you prefer to install them [manually](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#installing-manually-optional), click on the link. *(Optional)*
Once *prerequisites* finish installing.
#####Part III
Choose either
`1` to get the **most updated build of NadekoBot**
or
`2` to get the **previously stable build of NadekoBot**
and then press `enter` key.
Once Installation is completed you should see the options again.
Next, check out:
2017-02-02 16:45:06 +00:00
#####Part IV (Optional)
If you prefer to skip this step and want to do it [manually](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#setting-up-sftp) or already have the `credentials.json` file, click on the link. *(Optional)*
2017-02-01 22:22:16 +00:00
- [1. Setting up credentials.json](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#setting-up-credentialsjson)
- [2. To Get the Google API](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-nadekobot-for-music)
- [3. JSON Explanations for other APIs](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/)
You will need the following for the next step:
![botimg](https://cdn.discordapp.com/attachments/251504306010849280/276455844223123457/Capture.PNG)
- **Bot's Client ID** and **Bot's ID** (both are same) [(*required)](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-credentialsjson-file)
- **Bot's Token** (not client secret) [(*required)](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-credentialsjson-file)
- Your **Discord userID** [(*required)](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-credentialsjson-file)
- **Google Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-nadekobot-for-music)
- **LoL Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/)
- **Mashape Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/)
- **Osu Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/)
- **Sound Cloud Client Id** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/)
Once you have acquired them, press `6` to **Set up credentials.json**
2017-02-02 16:27:46 +00:00
You will be asked to enter the required informations, just follow the on-screen instructions and enter the required information.
*i.e* If you are asked **Bot's Token**, then just copy and paste or type the **Bot's Token** and press `enter` key.
2017-02-01 22:22:16 +00:00
2017-02-02 16:27:46 +00:00
(If you want to skip any optional infos, just press `enter` key without typing/pasting anything.)
2017-02-01 22:22:16 +00:00
Once done,
#####Part V
2017-02-04 08:49:35 +00:00
You should see the options again.
2017-02-01 22:22:16 +00:00
Next, press `3` to **Run Nadeko (Normally)**
Check in your discord server if your new bot is working properly.
#####Part VI
2017-02-04 08:49:35 +00:00
If your bot is working properly in your server, type `.die` to **shut down the bot**, then press `7` to **exit**.
Next, [Run your bot again with **tmux**.](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#running-nadekobot)
2017-02-01 22:22:16 +00:00
2017-02-02 16:27:46 +00:00
[Check this when you need to **restart** your **NadekoBot** anytime later along with tmux session.](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#restarting-nadeko)
2017-02-01 22:22:16 +00:00
####Running NadekoBot
**Create a new Session:**
- `tmux new -s nadeko`
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer and remember its your session name)* so you can run the bot in background without having to keep the PuTTY running.
**Next, we need to run `linuxAIO.sh` in order to get the latest running scripts with patches:**
- `cd ~ && bash linuxAIO.sh`
2017-02-04 08:49:35 +00:00
**From the options,**
2017-02-01 22:22:16 +00:00
2017-02-04 08:49:35 +00:00
Choose `3` to **Run NadekoBot normally.**
2017-02-01 22:22:16 +00:00
**NOTE:** With option `3` (Running Normally), if you use `.die` [command](http://nadekobot.readthedocs.io/en/latest/Commands%20List/#administration) in discord. The bot will shut down and will stay offline until you manually run it again. (best if you want to check the bot.)
2017-02-04 08:49:35 +00:00
Choose `4` to **Run NadekoBot with Auto Restart.**
It will show you more options:
```
1. Run Auto Restart normally without Updating.
2. Auto Restart and Update with Dev Build (latest)
3. Auto Restart and Update with Stable Build
4. Exit
```
2017-02-01 22:22:16 +00:00
**NOTE:** With option `4` (Running with Auto Restart), bot will auto run if you use `.die` [command](http://nadekobot.readthedocs.io/en/latest/Commands%20List/#administration) making the command `.die` to function as restart.
See how that happens:
![img9](https://cdn.discordapp.com/attachments/251504306010849280/251506312893038592/die_explaination.gif)
**Remember** that, while running with Auto Restart, you will need to [close the tmux session](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#restarting-nadeko) to stop the bot completely.
**Now check your Discord, the bot should be online**
2017-02-04 08:49:35 +00:00
Next to **move the bot to background** and to do that, press **CTRL+B+D** (that will detach the nadeko session using TMUX) and you can finally close **PuTTY** if you want.
2017-02-01 22:22:16 +00:00
####Restarting Nadeko
2017-02-02 16:27:46 +00:00
**Restarting NadekoBot:**
**If** you have chosen option `4` to **Run Nadeko with Auto Restart** from Nadeko's `linuxAIO.sh` *[(you got it from this step)](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#getting-nadekobot)*
You can simply type `.die` in the server you have your NadekoBot to make her restart.
2017-02-01 22:22:16 +00:00
**Restarting Nadeko with the Server:**
Open **PuTTY** and login as you have before, type `reboot` and hit Enter.
**Restarting Manually:**
- Kill your previous session, check with `tmux ls`
- `tmux kill-session -t nadeko` (don't forget to replace "nadeko" to what ever you named your bot's session)
- [Run the bot again.](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#running-nadekobot)
####Updating Nadeko
2017-02-02 16:27:46 +00:00
- Connect to the terminal through **PuTTY**.
2017-02-01 22:22:16 +00:00
- `tmux kill-session -t nadeko` (don't forget to replace **nadeko** in the command with the name of your bot's session)
- Make sure the bot is **not** running.
- `tmux new -s nadeko` (**nadeko** is the name of the session)
- `cd ~ && bash linuxAIO.sh`
- Choose either `1` or `2` to update the bot with **latest build** or **stable build** respectively.
- Choose either `3` or `4` to run the bot again with **normally** or **auto restart** respectively.
2017-02-02 16:27:46 +00:00
- Done. You can close **PuTTY** now.
2017-02-01 22:22:16 +00:00
####Installing Manually (Optional)
#####Installing Git
![img1](https://cdn.discordapp.com/attachments/251504306010849280/251504416019054592/git.gif)
2017-01-14 16:45:59 +00:00
Ubuntu:
`sudo apt-get install git -y`
2016-07-24 11:59:30 +00:00
2017-01-14 16:45:59 +00:00
CentOS:
`yum -y install git`
**NOTE:** If the command is not being initiated, hit **Enter**
2017-02-01 22:22:16 +00:00
#####Installing .NET Core SDK
![img2](https://cdn.discordapp.com/attachments/251504306010849280/251504746987388938/dotnet.gif)
2017-01-14 16:45:59 +00:00
Go to [this link](https://www.microsoft.com/net/core#ubuntu) (for Ubuntu) or to [this link](https://www.microsoft.com/net/core#linuxcentos) (for CentOS) provided by microsoft for instructions on how to get the most up to date version of the dotnet core sdk!
Make sure that you're on the correct page for your distribution of linux as the guides are different for the various distributions.
Install the **currently supported version** `1.0.0-preview2-1-003177`.
You can find it [here](https://github.com/dotnet/core/blob/master/release-notes/download-archives/1.1-preview2.1-download.md) if you prefer manual installing `dpkg` files.
2016-07-24 11:59:30 +00:00
We'll go over the steps here for few linux distributions, accurate as of March 08, 2017:
**NOTE:** .NET CORE SDK only supports 64-bit Linux Operating Systems (Raspberry Pis are not supported because of this)
**Ubuntu x64 17.04 & 16.10**
```sh
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ yakkety main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update && sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177 -y
2016-11-11 11:28:40 +00:00
```
**Ubuntu x64 16.04**
```sh
2016-11-11 11:28:40 +00:00
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update && sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177 -y
2016-11-11 11:28:40 +00:00
```
**Ubuntu x64 14.04**
```sh
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update && sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177 -y
```
**Debian 8 x64**
```sh
sudo apt-get install curl libunwind8 gettext -y
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835021
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
```
**CentOS 7 x64**
```sh
sudo yum install libunwind libicu -y
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
```
2016-07-17 13:58:16 +00:00
2017-02-01 22:22:16 +00:00
#####Installing Opus Voice Codec and libsodium
![img3](https://cdn.discordapp.com/attachments/251504306010849280/251505294654308353/libopus.gif)
2017-01-14 16:45:59 +00:00
Ubuntu:
`sudo apt-get install libopus0 opus-tools libopus-dev libsodium-dev -y`
2017-01-14 16:45:59 +00:00
CentOS:
`yum -y install opus opus-devel`
2017-02-01 22:22:16 +00:00
#####Installing FFMPEG
![img4](https://cdn.discordapp.com/attachments/251504306010849280/251505443111829505/ffmpeg.gif)
2017-01-14 16:45:59 +00:00
Ubuntu:
`apt-get install ffmpeg -y`
2017-01-14 16:45:59 +00:00
Centos:
```sh
2017-01-14 16:45:59 +00:00
yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm epel-release
yum -y install ffmpeg
```
**NOTE:** If you are running **UBUNTU 14.04**, you must run these first:
```sh
2016-11-11 11:33:46 +00:00
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
2016-11-11 11:33:46 +00:00
sudo apt-get dist-upgrade
```
**Before executing:** `sudo apt-get install ffmpeg`
2016-07-14 16:14:19 +00:00
**NOTE:** If you are running **Debian 8 Jessie**, please, follow these steps:
2016-07-14 16:14:19 +00:00
```sh
2016-11-11 11:33:46 +00:00
sudo apt-get update
echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/debian-backports.list
2016-11-11 11:33:46 +00:00
sudo apt-get update && sudo apt-get install ffmpeg -y
```
2016-07-14 16:14:19 +00:00
2017-02-01 22:22:16 +00:00
#####Installing TMUX
![img5](https://cdn.discordapp.com/attachments/251504306010849280/251505519758409728/tmux.gif)
2017-01-14 16:45:59 +00:00
Ubuntu:
`sudo apt-get install tmux -y`
2017-01-14 16:45:59 +00:00
Centos:
`yum -y install tmux`
2017-02-01 22:22:16 +00:00
####Guide for Advance Users (Optional)
**Skip this step if you are a Regular User or New to Linux.**
2016-11-30 13:45:01 +00:00
[![img7][img7]](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#getting-nadekobot)
2016-11-30 13:45:01 +00:00
- Right after [Getting NadekoBot](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#getting-nadekobot)
- `cd NadekoBot/src/NadekoBot/` (go to this folder)
- `pico credentials.json` (open credentials.json to edit)
2016-11-30 13:45:01 +00:00
- Insert your bot **Client ID, Bot ID** (should be same as your Client ID) **and Token** if you got it following [Creating and Inviting bot](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#creating-and-inviting-bot).
- Insert your own ID in Owners ID follow: [Setting up credentials.json](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-credentialsjson-file)
- And Google API from [Setting up NadekoBot for Music](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-nadekobot-for-music)
- Once done, press `CTRL+X`
- It will ask for "Save Modified Buffer?", press `Y` for yes
- It will then ask "File Name to Write" (rename), just hit `Enter` and Done.
2016-11-30 13:45:01 +00:00
- You can now move to [Running NadekoBot](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#running-nadekobot)
####Setting up SFTP
2017-02-01 22:22:16 +00:00
- Open **WinSCP**
- Click on **New Site** (top-left corner).
- On the right-hand side, you should see **File Protocol** above a drop-down selection menu.
- Select **SFTP** *(SSH File Transfer Protocol)* if its not already selected.
- Now, in **Host name:** paste or type in your `Digital Ocean Droplets IP address` and leave `Port: 22` (no need to change it).
2016-07-24 11:59:30 +00:00
- In **Username:** type `root`
- In **Password:** type `the new root password (you changed at the start)`
2017-02-01 22:22:16 +00:00
- Click on **Login**, it should connect.
- It should show you the NadekoBot folder which was created by git earlier on the right-hand side window.
- Open that folder, then open the `src` folder, followed by another `NadekoBot` folder and you should see `credentials.json` there.
####Setting up credentials.json
- Copy the `credentials.json` to desktop
2016-11-30 13:45:01 +00:00
- EDIT it as it is guided here: [Setting up credentials.json](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-credentialsjson-file)
2017-02-01 22:22:16 +00:00
- Paste/put it back in the folder once done. `(Using WinSCP)`
- **If** you already have Nadeko 1.0 setup and have `credentials.json` and `NadekoBot.db`, you can just copy and paste the `credentials.json` to `NadekoBot/src/NadekoBot` and `NadekoBot.db` to `NadekoBot/src/NadekoBot/bin/Release/netcoreapp1.0/data` using WinSCP.
2016-11-30 13:45:01 +00:00
- **If** you have Nadeko 0.9x follow the [Upgrading Guide](http://nadekobot.readthedocs.io/en/latest/guides/Upgrading%20Guide/)
2016-11-11 11:52:46 +00:00
####Setting up Music
2016-11-30 13:45:01 +00:00
To set up Nadeko for music and Google API Keys, follow [Setting up NadekoBot for Music](http://nadekobot.readthedocs.io/en/latest/guides/Windows%20Guide/#setting-up-nadekobot-for-music)
Once done, go back to **PuTTY**
2017-02-01 22:22:16 +00:00
####Some more Info
2016-05-08 18:39:33 +00:00
2017-02-01 22:22:16 +00:00
#####Info about tmux
- If you want to **see the sessions** after logging back again, type `tmux ls`, and that will give you the list of sessions running.
- If you want to **switch to/ see that session**, type `tmux a -t nadeko` (**nadeko** is the name of the session we created before so, replace **“nadeko”** with the session name you created.)
- If you want to **kill** NadekoBot **session**, type `tmux kill-session -t nadeko`
2017-02-01 22:22:16 +00:00
#####Alternative way to Install
2016-11-30 13:45:01 +00:00
If the [Nadeko installer](http://nadekobot.readthedocs.io/en/latest/guides/Linux%20Guide/#getting-nadekobot) shows any kind error, check if you have the `linuxAIO.sh` file and make sure its not renamed or if you want to manually install the bot. Use the following command(s):
![img6](https://cdn.discordapp.com/attachments/251504306010849280/251505587089571850/getting_nadeko.gif)
`cd ~ && curl -L https://github.com/Kwoth/NadekoBot-BashScript/raw/master/nadeko_installer.sh | sh`
**OR**
```sh
2017-02-01 22:22:16 +00:00
cd ~ && git clone -b dev --recursive --depth 1 https://github.com/Kwoth/NadekoBot.git
2016-11-11 11:33:46 +00:00
cd ~/NadekoBot/discord.net/src/Discord.Net && dotnet restore && cd ../Discord.Net.Commands && dotnet restore && cd ../../../src/NadekoBot/ && dotnet restore && dotnet build --configuration Release
```
If you are getting error using the above steps try:
2016-05-08 22:02:08 +00:00
```sh
2016-11-11 11:33:46 +00:00
cd ~/NadekoBot/discord.net && dotnet restore -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json && dotnet restore
cd ~/NadekoBot/src/NadekoBot/ && dotnet restore && dotnet build --configuration Release
```
[img7]: https://cdn.discordapp.com/attachments/251504306010849280/251505766370902016/setting_up_credentials.gif