mirror of
https://gitea.blesmrt.net/mikaela/shell-things.git
synced 2024-11-14 04:19:23 +01:00
40 lines
1.0 KiB
Bash
Executable File
40 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -x
|
|
|
|
# I learned that not only systemd-resolved does this, but NetworkManager as
|
|
# well. I think it's even less likely I use this than the systemd-resolved
|
|
# one, but anyway
|
|
|
|
# I know there are old versions that used something else, but I don't remember
|
|
# that name and they are ancient.
|
|
if ! hash nmcli 2>/dev/null; then
|
|
echo "You don't seem to have NetworkManager (or nmcli) installed." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# Require root or exit
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "This script requires root." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# It's pointless to make a dead symlink as it must be running
|
|
systemctl enable --now NetworkManager.service
|
|
|
|
# In case I am behind the /etc/resolv.conf, it's immutable and read-only,
|
|
# which won't allow it to be rewritten.
|
|
chattr -V -i /etc/resolv.conf
|
|
chmod -v +w /etc/resolv.conf
|
|
|
|
# It must be removed if it's not a symlink
|
|
rm -v /etc/resolv.conf
|
|
|
|
# and finally making the symlink
|
|
ln -sfv /var/run/NetworkManager/resolv.conf /etc/resolv.conf
|
|
|
|
# Let's just see it's ok
|
|
ls -l /etc/resolv.conf
|
|
cat /etc/resolv.conf
|
|
|
|
set +x
|