- Shell 100%
| nmupdhostnames.bash | ||
| nmupdhostnames.conf | ||
| README.md | ||
What is this?
This is nmupdhostnames, a bash script for (NetworkManager)[https://networkmanager.dev/] to automatically update /etc/hosts file with two hostnames that you can define in a config file, one for the IP address of the hotspot device and one for the IP address that it assigns to the device running NetworkManager, when NetworkManager uses one of the connections that you also can define in the same config file.
Installation
Clone this repo on the device running NetworkManager:
git clone https://git.lattuga.net/Jones/nmupdhostnames.git
Enter its local directory:
cd nmupdhostnames
Edit nmupdhostnames.conf (each setting is explained in a comment there).
Change nmupdhostnames.conf mode to make it readable and writeable only by its owner:
chmod 600 nmupdhostnames.conf
Change nmupdhostnames.bash mode to make it readable, writeable and executable only by its owner:
chmod 700 nmupdhostnames.bash
Change nmupdhostnames.conf and nmupdhostnames.bash owner to root:
sudo chown root:root nmupdhostnames.*
Copy nmupdhostnames.conf into /etc:
sudo cp nmupdhostnames.conf /etc
Copy nmupdhostnames.bash to /etc/NetworkManager/dispatcher.d:
sudo cp nmupdhostnames.bash /etc/NetworkManager/dispatcher.d
Done :-)
Usage
When nmupdhostnames adds or updates the two hostnames in /etc/hosts, or if an error occurs, it tells with a message in the system log.
Disinstallation
Delete /etc/NetworkManager/dispatcher.d/nmupdhostnames.bash:
sudo rm /etc/NetworkManager/dispatcher.d/nmupdhostnames.bash
Optionally delete /etc/nmupdhostnames.conf:
sudo rm /etc/nmupdhostnames.conf