first-commit

This commit is contained in:
zeaslity
2023-05-15 16:49:09 +08:00
commit 06cba6ca3c
816 changed files with 157018 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# 判断命令是否存在
command_exists() {
command -v "$@" >/dev/null 2>&1
}
# 获取服务器的公网IP地址
get_Internal_IP() {
local Internal_IP=""
local Network_Manage_Tool=""
if command_exists ip; then
Network_Manage_Tool=$(ip addr)
Ethernet_Interface_Name=$(echo "$Network_Manage_Tool" | grep -Eo "eth([0-9]{1,3})|eno([0-9]{1,3})|ens([0-9]{1,3})" | head -n 1)
echo "正在使用ip addr命令获取内网的IP地址"
Internal_IP=$(ip addr show ${Ethernet_Interface_Name} | grep 'inet ' | head -1 | awk '{print $2}' | cut -f1 -d'/')
elif command_exists ifconfig; then
Network_Manage_Tool=$(ifconfig)
Ethernet_Interface_Name=$(echo "$Network_Manage_Tool" | grep -Eo "eth([0-9]{1,3})|eno([0-9]{1,3})|ens([0-9]{1,3})" | head -n 1)
echo "正在使用ifconfig命令获取内网的IP地址"
Internal_IP=$(ifconfig ${Ethernet_Interface_Name} | grep 'inet ' | head -1 | awk '{print $2}' | cut -f1 -d'/')
fi
echo ""
echo "$Internal_IP"
echo ""
}
get_Internal_IP