blob: 2fb8b30d143fe80b8c4f7ba348b4268afeee117a (
plain) (
tree)
|
|
#!/bin/bash
# dotfiles -- scripts/eth.sh
# author: johannst
if="${BLOCK_INSTANCE:-enp0s25}"
[[ ! -d /sys/class/net/${if} ]] && exit 0
# operstate: down, up
[[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]] && exit 0
# first ipv4 addr
IP_ADDR=$(ip address show $if | grep 'inet ' | sed 's/\s\+inet \([0-9.]\+\)\/.*/\1/')
echo "$IP_ADDR"
|