Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. The shebang line has been changed from `#!/usr/bin/env sh` to `#!/bin/sh`. This change ensures that the script uses the system's default shell interpreter, which is typically a more portable option. 2. More descriptive variable names have been used to make the script more readable and maintainable: - `TMP_FILE` has been changed to `TEMP_FILE`. - `IPv4_URL` has been changed to `CLOUDFLARE_IPv4_URL`. - `IPv6_URL` has been changed to `CLOUDFLARE_IPv6_URL`. - `PORTS` has been changed to `ALLOWED_PORTS`. - `COMMENT` has been changed to `RULE_COMMENT`. 3. Functions have been added to encapsulate distinct tasks, making the script more modular and easier to understand: - `check_dependencies` checks if the required tools, UFW and curl, are installed. - `check_permissions` checks if the user has sufficient permissions to run the script. - `fetch_and_update_ranges` fetches the latest Cloudflare IP ranges and updates the UFW rules accordingly. - `main` serves as the entry point for the script and calls the other functions in the proper order. 4. Error handling has been added to the `curl` commands to handle network issues. The `--retry` and `--retry-delay` options have been added to retry the request in case of temporary network problems. 5. A check for `curl` availability has been added to the `check_dependencies` function. This ensures the script will abort if `curl` is not installed. 6. Usage information and documentation have been added to the script. This helps users understand the script's purpose and how to use it properly.
- Loading branch information