Add: script for auto testing resolve domain to specific interface
All checks were successful
/ test (push) Successful in 19s

This commit is contained in:
Aroy-Art 2024-03-11 23:01:49 +01:00
parent 35eb3e02b1
commit 6926af6485
Signed by: Aroy
GPG key ID: DB9689E9391DD156
2 changed files with 34 additions and 1 deletions

View file

@ -15,7 +15,7 @@ This repo holds most of my random small scripts, configs, paws(blobs)
* [Shell Scripts](#shell-scripts) * [Shell Scripts](#shell-scripts)
* [24-bit-color.sh](#24-bit-color-sh) * [24-bit-color.sh](#24-bit-color-sh)
* [rsync-incremental-backups.sh](#rsync-incremental-backups-sh) * [rsync-incremental-backups.sh](#rsync-incremental-backups-sh)
* [set_dns_search_domain.sh](#set_dns_search_domain-sh)
--- ---
## Configs ## Configs
@ -48,3 +48,26 @@ This script echoes a bunch of 24-bit color codes to the terminal to demonstrate
### rsync-incremental-backups.sh ### rsync-incremental-backups.sh
This script performs incremental backups of the specified source directory using rsync, and it keeps a symbolic link called 'latest' pointing to the most recent backup for easy reference. The script also logs backup details in a log file with a timestamp. Make sure to replace `<input folder>` and `<output folder>` with your actual source and backup directories. This script performs incremental backups of the specified source directory using rsync, and it keeps a symbolic link called 'latest' pointing to the most recent backup for easy reference. The script also logs backup details in a log file with a timestamp. Make sure to replace `<input folder>` and `<output folder>` with your actual source and backup directories.
---
### set_dns_search_domain.sh
Is a small script that runs the resolvectl domain command when the specific a Wi-Fi network is gets connected.
* **To configure the system to run the script:**
You can configure your system to execute the script whenever the Wi-Fi connection event occurs. This typically involves using network manager scripts or similar mechanisms provided by your Linux distribution.
replace the `<Your_Targeted_WiFi_SSID>`, `<interface>` and `<domain>` with the actual values you have.
For example, with NetworkManager, you can place the script in the /etc/NetworkManager/dispatcher.d directory. Scripts in this directory are executed when network events occur.
```Bash
sudo cp set_dns_search_domain.sh /etc/NetworkManager/dispatcher.d/
```
Ensure that the script has execute permissions:
```Bash
sudo chmod +x /etc/NetworkManager/dispatcher.d/set_dns_search_domain.sh
```
The script will be automatically executed whenever the Wi-Fi connection event occurs. When the targeted Wi-Fi network is connected, the DNS search domain will be set for the specified interface.

View file

@ -0,0 +1,10 @@
#!/bin/bash
# Check the SSID of the connected Wi-Fi network
current_ssid=$(nmcli -t -f active,ssid dev wifi | grep -E '^yes' | cut -d\: -f2)
# Check if the connected Wi-Fi network is the one you want to target
if [ "$current_ssid" = "<Your_Targeted_WiFi_SSID>" ]; then
# Set the DNS search domain for the taget interface
resolvectl domain <interface> <domain>
fi