This bash script automates the process of mapping the public port for qBittorrent using the natpmp protocol. It periodically checks for changes in the mapped public port and updates the qBittorrent port accordingly.
- qBittorrent: Ensure that
qBittorrentis installed on your system. If not, the script will attempt to install it usingsudo dnf install -y qbittorrent.
- Copy the script to your local machine or server.
- Make the script executable:
chmod +x torrent.sh
- Run the script:
./torrent.sh
-
The script checks if
qBittorrentis installed. If not, it installs it using the package manager (dnfin this case). -
It enters a continuous loop, checking for changes in the mapped public port every 45 seconds.
-
It uses the
natpmpctool to obtain the gateway address and map the public port using the natpmp protocol. -
If the mapping is successful, the script extracts the mapped public port and compares it with the previous port.
-
The script repeats the process in the loop, continuously monitoring for changes in the mapped public port.
- Adjust the
sleepduration at the end of the script to control how frequently the script checks for changes (default is 45 seconds).
-
Ensure that you have the necessary permissions to install packages using
sudoor run the script with appropriate privileges. -
This script is designed for systems using the
dnfpackage manager. If you are using a different package manager, update the installation command accordingly. -
It's recommended to review and customize the script based on your specific requirements and system configuration.