check_ip.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # LGSM check_ip.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="271215"
  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 [ "${gamename}" != "Teamspeak 3" ]; then
  9. if [ ! -f "/bin/ip" ]; then
  10. ipcommand="/sbin/ip"
  11. else
  12. ipcommand="ip"
  13. fi
  14. getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
  15. getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)
  16. if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
  17. if [ "${getipwc}" -ge "2" ]; then
  18. fn_print_warn "Multiple active network interfaces found.\n\n"
  19. echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
  20. echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
  21. echo -en "${getip}\n"
  22. echo -en ""
  23. echo -en "http://gameservermanagers.com/network-interfaces\n"
  24. echo -en ""
  25. exit 1
  26. else
  27. ip=${getip}
  28. fi
  29. fi
  30. fi