2015-01-30 14:29:03 +08:00
##Instructions
This instruction primarily tested on Linux but, may be, will work on other POSIX-compliant systems.
2014-01-19 13:43:31 +08:00
2014-08-17 13:53:54 +08:00
For security reasons we run the daemon under its own user.
2015-01-30 14:29:03 +08:00
2014-08-17 13:53:54 +08:00
Create a new user by executing the following:
```sh
2015-01-30 14:29:03 +08:00
sudo useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
2014-01-19 15:50:44 +08:00
```
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
Copy `tox-bootstrapd.conf` file to where `CFGFILE` variable from `tox-bootstrapd.sh` tells (for `init.d` users) or `ExecStart=` from `tox-bootstrap.service` ( for `systemd` users). By default it's `/etc/tox-bootstrapd.conf` .
Go over everything in `tox-bootstrapd.conf` . Make sure `pid_file_path` matches `PIDFILE` from `tox-bootstrapd.sh` (`init.d`) or `PIDFile=` from `tox-bootstrap.service` AND file in `ExecStartPre` (`systemd`).
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
Restrict access to home directory:
2014-08-17 13:53:54 +08:00
```sh
2015-01-30 14:29:03 +08:00
sudo chmod 700 /var/lib/tox-bootstrapd
2014-01-19 15:50:44 +08:00
```
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
##For `init.d` users:
2014-08-17 13:53:54 +08:00
2015-01-30 14:29:03 +08:00
Look at the variable declarations in the beginning of `tox-bootstrapd.sh` init script to see if you need to change anything for it to work for you. The default values must be fine for most users and we assume that you use those next.
2014-08-17 13:53:54 +08:00
2015-01-30 14:29:03 +08:00
Copy `tox-bootstrapd.sh` init file to `/etc/init.d/tox-bootstrapd` (note the disappearance of ".sh" ending).
```sh
sudo cp tox-bootstrapd.sh /etc/init.d/tox-bootstrapd
```
2014-08-17 13:53:54 +08:00
Set permissions for the init system to run the script:
```sh
sudo chmod 755 /etc/init.d/tox-bootstrapd
2014-01-19 15:50:44 +08:00
```
2014-01-19 13:43:31 +08:00
2014-08-17 13:53:54 +08:00
Make the init system aware of the script:
```sh
sudo update-rc.d tox-bootstrapd defaults
```
2014-01-19 13:43:31 +08:00
2014-08-17 13:53:54 +08:00
Start the daemon:
```sh
sudo service tox-bootstrapd start
2014-01-19 15:50:44 +08:00
```
2014-08-17 13:53:54 +08:00
Verify it's running:
```sh
sudo service tox-bootstrapd status
2014-01-19 15:50:44 +08:00
```
2014-01-19 13:43:31 +08:00
2014-08-17 13:53:54 +08:00
Get your public key and check that the daemon initialized correctly:
```sh
sudo grep "tox-bootstrapd" /var/log/syslog
```
2014-01-19 15:50:44 +08:00
2015-01-30 14:29:03 +08:00
##For `systemd` users:
Copy tox-bootstrap.service to /etc/systemd/system/:
```sh
sudo cp tox-bootstrap.service /etc/systemd/system/
```
Make sure, that path to `chown` and `mkdir` is correct in `tox-bootstrap.service` (they may be different in some distributions, by default `/bin/chown` and `/bin/mkdir` )
You must uncomment the next line in tox-bootstrap.service, if you want to use port number < 1024
#CapabilityBoundingSet =CAP_NET_BIND_SERVICE
and, possibly, install `libcap2-bin` or `libcap2` package, depending of your distribution.
2014-01-19 15:50:44 +08:00
2015-01-30 14:29:03 +08:00
Reload systemd units definitions, enable service for automatic start (if needed), and start it:
```sh
sudo systemctl daemon-reload
sudo systemctl enable tox-bootstrap.service
sudo systemctl start tox-bootstrap.service
```
2014-01-19 15:50:44 +08:00
###Troubleshooting:
2014-08-17 13:53:54 +08:00
- Check daemon's status:
```sh
2015-01-30 14:29:03 +08:00
#init.d
2014-08-17 13:53:54 +08:00
sudo service tox-bootstrapd status
2015-01-30 14:29:03 +08:00
#systemd
sudo systemctl status tox-bootstrap.service
2014-01-19 15:50:44 +08:00
```
2014-08-17 13:53:54 +08:00
- Check the log for errors:
```sh
2015-01-30 14:29:03 +08:00
#init.d
2014-08-17 13:53:54 +08:00
sudo grep "tox-bootstrapd" /var/log/syslog
2015-01-30 14:29:03 +08:00
#systemd
sudo journalctl -f _SYSTEMD_UNIT=tox-bootstrap.service
2014-01-19 15:50:44 +08:00
```
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
`init.d` :
2014-08-17 13:53:54 +08:00
- Check that variables in the beginning of `/etc/init.d/tox-bootstrapd` are valid.
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
Common:
- Make sure tox-bootstrapd user has write permission for keys and pid files (in systemd pid file insured by unit definition).
- Make sure tox-bootstrapd has read permission for the config file.
2014-01-19 13:43:31 +08:00
2015-01-30 14:29:03 +08:00
- Make sure tox-bootstrapd location matches its path in init scripts, if you specified non-default `--prefix` , when building.