adding function to switch DNS nameservers + monitoring of current settings; adding a README
This commit is contained in:
46
README.md
Normal file
46
README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Dynamic Status
|
||||
|
||||
These scripts control and monitor several functions of my computer. Most importantly it is possible to switch to a "offline status" which disables several internet-using monitoring functions.
|
||||
|
||||
status-ip.sh and status-misc.sh rely on `xfce-genmon-plugin` to show some status messages on the XFCE task bars.
|
||||
|
||||
status-interaction.sh enables users to actively change some values, e.g. the on-/offline status, the used DNS nameserver, and to trigger some actions, e.g. to send mails in an `msmtp` queue.
|
||||
|
||||
I tried to make it as compatible to as many systems as possible but some values are still hard-coded.
|
||||
|
||||
## DNS nameserver switch
|
||||
|
||||
This feature heavily depends on network-manager and it's dispatcher feature. In order to use it, put a file in `/etc/NetworkManager/dispatcher.d/` and name it `90-custom-resolv.conf` for example. Fill it:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#
|
||||
# Depending on dynamic status, override /etc/resolv.conf
|
||||
|
||||
CUSTOM=/tmp/resolv_custom.conf
|
||||
DEFAULT=/home/user/bin/default-nameserver.sh
|
||||
|
||||
if [ ! -e $CUSTOM ]; then # if file does not exists, use default nameserver script
|
||||
bash $DEFAULT
|
||||
echo "# 90-custom-resolvconf executed default-nameserver.sh" >> /etc/resolv.conf
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SET=$(cat $CUSTOM | head -n1 | awk '{print $NF}') # first line, last word
|
||||
|
||||
if [ "$SET" != "auto" ]; then
|
||||
cp -f /etc/resolv.conf /etc/resolv.conf.bak # backup original resolv config file
|
||||
cat $CUSTOM > /etc/resolv.conf # use custom file, update original one
|
||||
else
|
||||
echo "# 90-custom-resolvconf didn't change any substantial values here, just added this line." >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
```
|
||||
|
||||
The file has to be owned by root and be executable in order to function. It will either execute a script that sets default nameserver settings (in my case, it's localhost since I use a local dnsmasq), or take the values from another file which is created by switching the nameservers with status-interaction.sh.
|
||||
|
||||
Nameservers can be configured in `config.cfg` as value of `NS=`. It holds following pattern:
|
||||
|
||||
`set1(ip1,ip2,ip3)|set2(ip4,ip5)`
|
||||
|
||||
Please remember to put it between quotes.
|
||||
Reference in New Issue
Block a user