lgsm local mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
982 B

#!/bin/bash
# LinuxGSM check_ip.sh function
# Author: Daniel Gibbs
# Website: https://linuxgsm.com
# Description: Automatically identifies the server interface IP.
# If multiple interfaces are detected the user will need to manually set using ip="0.0.0.0".
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ ! -f "/bin/ip" ]; then
ipcommand="/sbin/ip"
else
ipcommand="ip"
fi
getip=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|sort -u|grep -v 127.0.0)
getipwc=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|sort -u|grep -vc 127.0.0)
# Check if server has m ultiple IP addresses
# If the ip variable is set by user
if [ "${ip}" != "0.0.0.0" ]||[ "${ip}" != "" ]; then
queryip=( "${ip}" )
# If ip is not set by user
else
queryip=( "${getip}" )
fi
echo "###### DEV IP CHECK ######"
echo "IP: ${IP}"
echo "EXTIP: ${extip}"
echo "DISPLAYIP: ${displayip}"
echo "QUERYIP: ${queryip}"