diff --git a/Running-qBittorrent-without-X-server-(WebUI-only---systemd-service-setup,-Ubuntu-15.04-or-newer).md b/Running-qBittorrent-without-X-server-(WebUI-only---systemd-service-setup,-Ubuntu-15.04-or-newer).md index 072b366..108a711 100644 --- a/Running-qBittorrent-without-X-server-(WebUI-only---systemd-service-setup,-Ubuntu-15.04-or-newer).md +++ b/Running-qBittorrent-without-X-server-(WebUI-only---systemd-service-setup,-Ubuntu-15.04-or-newer).md @@ -8,9 +8,10 @@ This guide will show you how to setup `qbittorrent-nox` to run as a managed back It can then be customized like any other `systemd` service, to automatically start on boot, for instance. For Ubuntu, it's advisable to install `qbittorrent-nox` from the official PPA to get the latest version. -Refer to https://github.com/qbittorrent/qBittorrent/wiki/Installing-qBittorrent under > Other Binary Packages +Refer to https://github.com/qbittorrent/qBittorrent/wiki/Installing-qBittorrent for more information. Side Note: these instructions are written with Ubuntu in mind but should be much the same if not exactly the same for any modern distro that uses `systemd`. +All instructions assume very basic knowledge of how to use the terminal. # Create a separate user account (optional - you may want to do this for security depending on your setup) @@ -60,7 +61,9 @@ The Web UI administrator password is still the default one: adminadmin This is a security risk, please consider changing your password from program preferences. ``` -Now will be a good time to make some changes. Visit your server with the given details, replacing localhost with your server's ip in the URL field, and log in with the given credentials. Then you can go to `Tools -> Options` to change settings such as the WebUI port. +Now is a good time to adjust some qBittorrent settings. +Visit the URL mentioned in `To control qBittorrent, access the Web UI at...` (might be different in your case), and log in with the credentials given. +Then you can go to `Tools -> Options` to change settings such as the WebUI port. Quit the running `qbittorent-nox` process by pressing `Ctrl-c` on your keyboard in the terminal: @@ -75,13 +78,14 @@ You can now stop impersonating the qbittorent user by executing the `exit` comma On Ubuntu, system-wide `systemd` service definition files are located under `/etc/systemd/system/` (for other distros it might be a different directory), so we'll create the service definition file for `qbittorrent-nox` there. -Create a new file `/etc/systemd/system/qbittorrent.service` with the appropriate permissions and text editor of your choice, for example: +Create a new file, `/etc/systemd/system/qbittorrent.service`, and edit it with the appropriate permissions and text editor of your choice, for example: ``` -sudo nano /etc/systemd/system/qbittorrent.service +sudoedit /etc/systemd/system/qbittorrent.service ``` -Save the file with the following contents or similar. You may modify them as-needed to better suit your needs: +Save the file with the following contents or similar. +You may modify them as-needed to better suit your needs: ``` [Unit] @@ -91,13 +95,13 @@ Wants=network-online.target After=network-online.target nss-lookup.target [Service] -# if you have systemd < 240 (Ubuntu 18.10 and earlier), you probably want to use Type=simple instead +# if you have systemd < 240 (Ubuntu 18.10 and earlier, for example), you probably want to use Type=simple instead Type=Exec # change user as needed User=qbtuser # notice that no -d flag needed ExecStart=/usr/bin/qbittorrent-nox -# uncomment the below for versions of qBittorrent below 4.2.x +# uncomment this for versions of qBittorrent < 4.2.0 to set the maximum number of open files to unlimited #LimitNOFILE=infinity [Install] @@ -106,7 +110,7 @@ WantedBy=multi-user.target Then run `sudo systemctl daemon-reload` to update the service manager. -The qBittorrent service is now ready to be used. To start the service with your system, refer to the next section. +The qBittorrent service is now ready to be used. To start the service on system boot, refer to the next section. # Controlling the service @@ -118,7 +122,10 @@ The qBittorrent service is now ready to be used. To start the service with your ``` Created symlink from /etc/systemd/system/multi-user.target.wants/qbittorrent.service to /etc/systemd/system/qbittorrent.service. ``` -- the previous command can be reverted with: `sudo systemctl disable qbittorrent` if you want to disable automatic startup of the qbittorrent service. +- the result of the previous command can be reverted with: `sudo systemctl disable qbittorrent`. +It simply disables automatic startup of the qBittorrent service. + +Refer to the `systemd` documentation to know of more operations you can do on services. # Logging @@ -132,9 +139,9 @@ sudo journalctl -u qbittorrent.service For more information on how to use and customize `systemd` logging, refer to its documentation. -# systemd Service Dependencies (optional) +# `systemd` Service Dependencies (optional) -Let's say that you've configured `qbittorrent-nox` to download files to a directory that is in another drive, for example, mounted on '/media/user/volume'. +Let's say that you've configured `qbittorrent-nox` to download files to a directory that is in another drive, for example, mounted on `/media/user/volume`. It's important that you edit the service created above and add some `systemd` dependencies to prevent qbittorrent from writing files on a directory that it should not, in case your drive fails to mount or is accidentally unmounted. After you added the mount point to the `/etc/fstab`, it should have a line like this: @@ -143,9 +150,10 @@ After you added the mount point to the `/etc/fstab`, it should have a line like UUID=c987355d-0ddf-4dc7-bbbc-bab8989d0690 /media/volume ext4 defaults,nofail 0 0 ``` -The 'nofail' option prevents the system from stopping the boot process in case the drive can't mount on startup. +The `nofail` option prevents the system from stopping the boot process in case the drive can't mount on startup. -You should edit `/etc/systemd/system/qbittorrent.service` to add 'local-fs.target' to the line 'After=network-online.target' and add the line 'BindsTo=media-volume.mount' to bind the qbittorrent service to the mount point that you want it to write the files. Your service file should look like this: +You should edit `/etc/systemd/system/qbittorrent.service` to add `local-fs.target` to the line `After=network-online.target` and add the line `BindsTo=media-volume.mount` to bind the qbittorrent service to the mount point that you want it to write the files. +Your service file should look like this: ``` # ... other stuff ... @@ -158,6 +166,9 @@ BindsTo=media-volume.mount # ... ``` -The 'media-volume.mount' is a `systemd` convention created dynamically at boot, based on the entries found in `/etc/fstab`. Conventions such as these are used by `systemd` to define conditions around services, such as requiring a drive to be mounted before the service will start. Refer to [Systemd.mount reference](http://man7.org/linux/man-pages/man5/systemd.mount.5.html) for further reading. It follows a simple logic: if your drive is mounted on '/media/volume', the unit name will be 'media-volume.mount', if it's on '/mnt/disk', the unit will be 'mnt-disk.mount'. +The `media-volume.mount` is a `systemd` convention created dynamically at boot, based on the entries found in `/etc/fstab`. +Conventions such as these are used by `systemd` to define conditions around services, such as requiring a drive to be mounted before the service will start. +Refer to [Systemd.mount reference](http://man7.org/linux/man-pages/man5/systemd.mount.5.html) for further reading. +It follows a simple logic: if your drive is mounted on `/media/volume`, the unit name will be `media-volume.mount`, if it's on `/mnt/disk`, the unit will be `mnt-disk.mount`. Using this to define the qbittorent-nox service file, if the drive can't mount when booting or if the drive is unmounted after qbittorrent has been started, it will not allow it to start or force it to stop, preventing from writing when the drive is not ready or present. \ No newline at end of file