Skip to content

Instantly share code, notes, and snippets.

@skokhanovskiy
Created September 29, 2023 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skokhanovskiy/1da5f0ebcfb53608db4a0c444baa7e9a to your computer and use it in GitHub Desktop.
Save skokhanovskiy/1da5f0ebcfb53608db4a0c444baa7e9a to your computer and use it in GitHub Desktop.
#!/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