|
|
@ -1,6 +1,6 @@ |
|
|
|
#!/bin/sh |
|
|
|
#!/bin/sh -e |
|
|
|
# |
|
|
|
# |
|
|
|
# 2012 Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> |
|
|
|
# 2019 Ander Punnar (ander-at-kvlt-dot-ee) |
|
|
|
# |
|
|
|
# |
|
|
|
# This file is part of cdist. |
|
|
|
# This file is part of cdist. |
|
|
|
# |
|
|
|
# |
|
|
@ -17,35 +17,14 @@ |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
# List all network interfaces in explorer/ifaces. One interface per line. |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# If your OS is not supported please provide a ifconfig output |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use ip, if available |
|
|
|
if command -v ip > /dev/null |
|
|
|
if command -v ip >/dev/null; then |
|
|
|
then |
|
|
|
ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' |
|
|
|
ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' |
|
|
|
exit 0 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ! command -v ifconfig >/dev/null; then |
|
|
|
elif command -v ifconfig > /dev/null |
|
|
|
# no ifconfig, nothing we could do |
|
|
|
then |
|
|
|
exit 0 |
|
|
|
ifconfig -a \ |
|
|
|
|
|
|
|
| sed -n -E 's/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' \ |
|
|
|
|
|
|
|
| sort -u |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
uname_s="$(uname -s)" |
|
|
|
|
|
|
|
REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "$uname_s" in |
|
|
|
|
|
|
|
Darwin) |
|
|
|
|
|
|
|
ifconfig -a | sed -n -E "$REGEXP" |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
Linux|*BSD) |
|
|
|
|
|
|
|
ifconfig -a | sed -n -r "$REGEXP" |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
*) |
|
|
|
|
|
|
|
echo "Unsupported ifconfig output for $uname_s" >&2 |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
esac |
|
|
|
|
|
|
|