| 1 |
Setup |
| 2 |
===== |
| 3 |
|
| 4 |
Prerequisites |
| 5 |
------------- |
| 6 |
|
| 7 |
Errbot runs under Python 3.6+ on Linux, Windows and Mac. |
| 8 |
|
| 9 |
Installation |
| 10 |
------------ |
| 11 |
|
| 12 |
Option 1: Use the package manager of your distribution (if available) |
| 13 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 14 |
|
| 15 |
On some distributions, Errbot is also available as a package via your usual package manager. |
| 16 |
In these cases, it is generally recommended to use your distribution's package instead of installing from PyPi but note |
| 17 |
that the version packaged with your distribution may be a few versions behind. |
| 18 |
|
| 19 |
Example of packaged versions of Errbot: |
| 20 |
|
| 21 |
* Arch: https://aur.archlinux.org/packages/python-err/ |
| 22 |
* Docker: https://hub.docker.com/r/errbotio/errbot |
| 23 |
* Gentoo: https://packages.gentoo.org/packages/net-im/err |
| 24 |
|
| 25 |
Option 2: Installing Errbot in a virtualenv (preferred) |
| 26 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 27 |
|
| 28 |
Installing into a `virtualenv`_ is **strongly** recommended. |
| 29 |
If you have virtualenv installed, you can do for example:: |
| 30 |
|
| 31 |
virtualenv --python `which python3` ~/.errbot-ve |
| 32 |
~/.errbot-ve/bin/pip install errbot |
| 33 |
|
| 34 |
|
| 35 |
If you have virtualenvwrapper installed it is even simpler:: |
| 36 |
|
| 37 |
mkvirtualenv -p `which python3` errbot-ve |
| 38 |
pip install errbot |
| 39 |
|
| 40 |
|
| 41 |
Option 3: Installing Errbot at the system level (not recommended) |
| 42 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 43 |
Errbot may be installed directly from PyPi using `pip`_ by issuing:: |
| 44 |
|
| 45 |
pip3 install errbot |
| 46 |
|
| 47 |
|
| 48 |
.. note:: |
| 49 |
Some of errbot's dependencies need to build C extensions |
| 50 |
which means you need to have development headers for some libraries installed. |
| 51 |
On Debian/Ubuntu these may be installed with |
| 52 |
`apt-get install python3-dev libssl-dev libffi-dev` |
| 53 |
Package names may differ on other OS's. |
| 54 |
|
| 55 |
.. _configuration: |
| 56 |
|
| 57 |
First run |
| 58 |
^^^^^^^^^ |
| 59 |
|
| 60 |
You can quickly configure Errbot by first creating a working directory and calling `errbot --init`:: |
| 61 |
|
| 62 |
mkdir ~/errbot-root |
| 63 |
cd ~/errbot-root |
| 64 |
errbot --init |
| 65 |
|
| 66 |
This will create a minimally working errbot in text (development) mode. You can try it right away:: |
| 67 |
|
| 68 |
errbot |
| 69 |
[...] |
| 70 |
>>> |
| 71 |
|
| 72 |
|
| 73 |
`>>>` is a prompt, you can talk to errbot directly. You can try:: |
| 74 |
|
| 75 |
!tryme |
| 76 |
!help |
| 77 |
!about |
| 78 |
|
| 79 |
Configuration |
| 80 |
------------- |
| 81 |
|
| 82 |
Once you have installed errbot and did :code:`errbot --init`, you will have to tweak the generated `config.py` to connect |
| 83 |
to your desired chat network. |
| 84 |
|
| 85 |
You can use :download:`config-template.py` as a base for your `config.py`. |
| 86 |
|
| 87 |
We'll go through the options that you absolutely must check now so that you can quickly get started |
| 88 |
and make further tweaks to the configuration later on. |
| 89 |
|
| 90 |
Open `config.py` in your favorite editor. |
| 91 |
The first setting to check or change if `BOT_DATA_DIR` if correct. |
| 92 |
This is the directory where the bot will store configuration data. |
| 93 |
|
| 94 |
The first setting to check or change `BOT_LOG_FILE` to be sure it point to a writeable directory on your system. |
| 95 |
|
| 96 |
The final configuration we absolutely must do is setting up a correct `BACKEND` which is set to `Text` by |
| 97 |
:code:`errbot --init` but you can change to the name of the chat system you want to connect to (see the template above |
| 98 |
for valid values). |
| 99 |
|
| 100 |
You absolutely need a `BOT_IDENTITY` entry to set the credentials Errbot will use to connect to the chat system. |
| 101 |
|
| 102 |
You can find here more details about configuring Errbot for some specific chat systems: |
| 103 |
|
| 104 |
|
| 105 |
.. toctree:: |
| 106 |
:maxdepth: 1 |
| 107 |
|
| 108 |
Discord Backend (in readthedocs) <https://err-backend-discord.readthedocs.io/> |
| 109 |
configuration/gitter |
| 110 |
configuration/irc |
| 111 |
configuration/mattermost |
| 112 |
configuration/slackv3 |
| 113 |
configuration/telegram |
| 114 |
configuration/xmpp |
| 115 |
|
| 116 |
|
| 117 |
Starting the daemon |
| 118 |
------------------- |
| 119 |
|
| 120 |
The first time you start Errbot, it is recommended to run it in foreground mode. This can |
| 121 |
be done with:: |
| 122 |
|
| 123 |
errbot |
| 124 |
|
| 125 |
If you installed errbot into a virtualenv (as recommended), |
| 126 |
call it by prefixing the virtualenv `bin/` directory:: |
| 127 |
|
| 128 |
/path/to/my/virtualenv/bin/errbot |
| 129 |
|
| 130 |
Please pass -h or --help to errbot to get a list of supported parameters. |
| 131 |
Depending on your situation, |
| 132 |
you may need to pass --config (or -c) |
| 133 |
pointing to the directory holding your `config.py` |
| 134 |
when starting Errbot. |
| 135 |
|
| 136 |
If all that worked out, |
| 137 |
you can now use the -d (or --daemon) parameter to run it in a detached mode:: |
| 138 |
|
| 139 |
errbot --daemon |
| 140 |
|
| 141 |
If you are going to run your bot all the time then using some process control system |
| 142 |
such as `supervisor`_ is highly recommended. Installing and configuring such a system |
| 143 |
is outside the scope of this document, however, we do provide some sample daemon configurations below. |
| 144 |
|
| 145 |
.. note:: |
| 146 |
There are two ways to gracefully shut down a running bot. |
| 147 |
|
| 148 |
You can use the :code:`!shutdown` command to do so via chat or you can send a `SIGINT` signal to the errbot process to do so from the commandline |
| 149 |
|
| 150 |
If you're running errbot in the foreground then pressing Ctrl+C is equivalent to sending `SIGINT`. |
| 151 |
|
| 152 |
Daemon Configurations |
| 153 |
^^^^^^^^^^^^^^^^^^^^^ |
| 154 |
|
| 155 |
These are a few example configurations using common init daemons: |
| 156 |
|
| 157 |
**supervisord** (`/etc/supervisor/conf.d/errbot.conf`) |
| 158 |
|
| 159 |
.. literalinclude:: ../code_examples/supervisord.conf |
| 160 |
:language: sh |
| 161 |
|
| 162 |
**systemd** (`/etc/systemd/system/errbot.service`) |
| 163 |
|
| 164 |
.. literalinclude:: ../code_examples/systemd.service |
| 165 |
:language: sh |
| 166 |
|
| 167 |
.. note:: |
| 168 |
|
| 169 |
Running errbot within a daemon process can have security implications if the daemon is started with an account containing elevated privileges. |
| 170 |
We encourage errbot **not** be run under a `root` or `administrator` account but under a non-privileged account. The command below creates a non-privileged `errbot` account on Linux:: |
| 171 |
|
| 172 |
$ useradd --no-create-home --no-user-group -g nogroup -s /bin/false errbot |
| 173 |
|
| 174 |
|
| 175 |
Upgrading |
| 176 |
--------- |
| 177 |
|
| 178 |
Errbot comes bundled with a plugin which automatically performs a periodic update check. |
| 179 |
Whenever there is a new release on PyPI, |
| 180 |
this plugin will notify the users set in `BOT_ADMINS` about the new version. |
| 181 |
|
| 182 |
Assuming you originally installed errbot using pip (see `installation`_), |
| 183 |
you can upgrade errbot in much the same way. |
| 184 |
If you used a virtualenv:: |
| 185 |
|
| 186 |
/path/to/my/virtualenv/bin/pip install --upgrade errbot |
| 187 |
|
| 188 |
Or if you used pip without virtualenv:: |
| 189 |
|
| 190 |
pip install --upgrade errbot |
| 191 |
|
| 192 |
It's recommended that you review the changelog before performing an upgrade |
| 193 |
in case backwards-incompatible changes have been introduced in the new version. |
| 194 |
The changelog for the release you will be installing can always be found |
| 195 |
on `PyPI <https://pypi.org/project/errbot/>`_. |
| 196 |
|
| 197 |
Provisioning (advanced) |
| 198 |
----------------------- |
| 199 |
|
| 200 |
See the :doc:`provisioning documentation </user_guide/provisioning>` |
| 201 |
|
| 202 |
.. _virtualenv: https://virtualenv.pypa.io/en/latest/ |
| 203 |
.. _pip: https://pip.pypa.io/en/stable/ |
| 204 |
.. _supervisor: http://supervisord.org/ |