Created
September 29, 2023 16:33
-
-
Save skokhanovskiy/1da5f0ebcfb53608db4a0c444baa7e9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
if which netplan 1>&2 2>/dev/null; then | |
ip -br link show up | awk '{print $1}' | while read -r int; do | |
if netplan ip leases 2>/dev/null; then | |
echo "${int} auto" | |
else | |
echo "${int} manual" | |
fi | |
done | |
exit $? | |
fi | |
if which ifcfg 1>&2 2>/dev/null; then | |
for file in /etc/sysconfig/network-scripts/ifcfg-*; do | |
int="$(basename "$file" | sed s/ifcfg-//)" | |
if grep -q ^BOOTPROTO=\"*dhcp "${file}"; then | |
echo "${int} auto" | |
else | |
echo "${int} manual" | |
fi | |
done | |
exit $? | |
fi | |
if which nmcli 1>&2 2>/dev/null; then | |
nmcli --get-values UUID connection show --active | while read -r int; do | |
echo "${int} $(nmcli --get-values ipv4.method connection show "${int}")" | |
done | |
exit $? | |
fi | |
echo "Unsupported network tool" >&2 | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment