fn_check_ip 1013 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # LGSM fn_check_ip function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="061115"
  6. # Description: Automatically identifies the server interface IP.
  7. # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0".
  8. if [ ! -f /bin/ip ]; then
  9. ipcommand="/sbin/ip"
  10. else
  11. ipcommand="ip"
  12. fi
  13. getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
  14. getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)
  15. if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
  16. if [ "${getipwc}" -ge "2" ]; then
  17. fn_printwarn "Multiple active network interfaces found.\n\n"
  18. echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
  19. echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
  20. echo -en "${getip}\n"
  21. echo -en ""
  22. echo -en "http://gameservermanagers.com/network-interfaces"
  23. echo -en ""
  24. exit 1
  25. else
  26. ip=${getip}
  27. fi
  28. fi