[add] get local ip, and write it to /opt/wd/99-Temp/localip.txt

This commit is contained in:
gitea 2023-07-05 20:56:53 +08:00
parent 3c1609aa68
commit 77a475b51e

15
update/localip.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
localip='/opt/wd/99-Temp/localip.txt'
> $localip
networks=('wlx90de80ca01ec' 'enp1s0' 'enp2s0')
for network in ${networks[@]}; do
ifconfig $network | grep -iq 'Device not found'
if [[ $? -ne 0 ]]; then
echo -n "$network: " >> $localip
ifconfig $network | grep 'inet ' | awk '{print $2}' >> $localip
echo >> $localip
fi
done
sed -i '/^$/d' $localip