How radinpirouz/dns_changer works
Main Components
• User Interface/Input: This is the command-line interaction in which the user runs the script and selects a DNS server.
• The Bash Script (dns.sh): This contains the logic for detecting /etc/resolv.conf’s status (such as being a symlink), unlinking it if necessary, and writing the new DNS configuration.
• System DNS Configuration: The /etc/resolv.conf file represents the final target component of the script’s actions.
• System Environment Dependencies: Indicate that the script requires Bash and sudo privileges (which implies that it interacts with system-level configuration and may also need to manage systemd-resolved).
Relationships and Interactions
• The user starts the process by executing the script.
• The script prompts for user selection from a predefined list.
• Upon selection, the script checks the type of /etc/resolv.conf (whether it’s a symlink) and unlinks it if necessary.
• The script then writes or creates a new /etc/resolv.conf with the chosen DNS.
Architectural Patterns or Design Principles
• Although it’s a single-file script, one can treat this as a simple pipeline of sequential operations.
• Error checking, user prompt flow, and system constraints (sudo privileges, symlink detection).
• That the design is “linear” or “procedural”, where each step depends on the previous operation.
Technologies and Dependencies
• Bash (as the scripting language).
• Linux system environment, with specific emphasis on systemd-resolved if present.
• Standard file manipulation commands and their execution through sudo.