代码拉取完成,页面将自动刷新
同步操作将从 小众镜像/wxMEdit 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/sh
#--------------------------------------------------------------
# FileName : SetNetworkInfo.sh
# Author : ghzhangz
# Descriptor: Shell 缓存网络配置
#--------------------------------------------------------------
#@example$>sh SetNetworkInfo.sh -d eth0 -i 172.17.0.0 -n 255.255.0.0 -g172.17.255.250 -b 127.0.0.0 -p
#------------------------------------------------
#declare variables
ARCH=ARM
#ARCH=LINUX
#use -p to enable debug print
debug=false
#---------------network cache path---------------
dataPath="/data/net/cache"
cacheFilePath="${dataPath}/netInfo.dat"
isAutoFlagPath_Prefix="${dataPath}/auto.f"
busyboxBinaryFilePath="/busybox"
busyboxInstallPath="/data/busybox"
nocheck=true
readShellPath="./ReadNetConfig.sh"
#---------------network cache path---------------
if [ $ARCH == "ARM" ]
then
awkPath="${busyboxInstallPath}/awk"
routePath="${busyboxInstallPath}/route"
trPath="${busyboxInstallPath}/tr"
else
awkPath="awk"
routePath="route"
trPath="tr"
fi
netWorkConfig=("ip" "netmask" "gateway" "broadcast" "device")
#------------------------------------------------
# Enumerate known network card names. If the configured network card name is not in the enumeration list,
# Add -s to the parameter for security check
#@example::./SetNetworkInfo.sh -d eth2 -i 172.17.0.2 -n 255.255.0.2 -g172.17.255.252 -b 127.0.0.2 -ps
NIC_NameArray=("eth0" "eth1" "wlan0" "lo")
#----------------------default ip config---------------------------------------
defaultNetConfig=("ifconfig eth0 192.168.0.100" "ifconfig eth1 192.168.1.100")
#------------------------------------------------------------------------------
function installBusybox() {
if [ ! -d "$busyboxInstallPath" ]; then
mkdir -p $busyboxInstallPath
fi
if test -e $awkPath
then
if [ $debug == true ]; then
echo "::$LINENO) $busyboxInstallPath already exists"
fi
else
if [ $debug == true ]; then
echo -e "::$LINENO)\033[33m awk file::$awkPath does not exist,busybox will be installed \033[0m"
fi
$busyboxBinaryFilePath --install -s $busyboxInstallPath
fi
}
function setOptions() {
while getopts ":d:b:g:n:i:p s w a c" opts
do
case $opts in
d) netWorkConfig[4]="${netWorkConfig[4]}=$OPTARG";;
b) netWorkConfig[3]="${netWorkConfig[3]}=$OPTARG";;
g) netWorkConfig[2]="${netWorkConfig[2]}=$OPTARG";;
n) netWorkConfig[1]="${netWorkConfig[1]}=$OPTARG";;
i) netWorkConfig[0]="${netWorkConfig[0]}=$OPTARG";;
c) rm -rf $dataPath
exit 0;;
w) source ${readShellPath}
startupDaemonIpAddress
exit 0;;
a) source ${readShellPath}
autoObtainsByDHCP $cacheFilePath $isAutoFlagPath_Prefix
exit 0;;
#Whether to enable the NIC name security check
s) nocheck=false ;;
p) debug=true ;;
*) echo -e "::$LINENO) \e[1;33;41m (Err)::Unknow arguments [$opts]=$OPTARG \e[0m"
exit 5;;
esac
done
# install awk
installBusybox
# test awk
$(type ${awkPath})
if [ $? -ne 0 ]
then
echo -e "::$LINENO) \e[1;33;41m (Err)::The awk Command cannot be execute. \e[0m"
exit 3
fi
if [ ! -n "$(echo ${netWorkConfig[4]} | ${awkPath} -F '=' '{print $2}')" ]; then
echo -e "::$LINENO) \e[1;33;41m (Err)::device name cannot be null. This can be specified using -d \e[0m"
exit 2
fi
if [ $nocheck != true ]; then
eq=false
for nicName in ${NIC_NameArray[*]}
do
if [ "$nicName" == "$(echo ${netWorkConfig[4]} | ${awkPath} -F '=' '{print $2}')" ]; then
eq=true
fi
done
if [ $eq != true ]; then
echo -e "::$LINENO) \e[1;33;41m (Err)::wrong argument device name [${netWorkConfig[4]}] \e[0m"
exit 3
fi
else
:
fi
}
function printOptions() {
if [ $debug == true ]; then
for item in ${netWorkConfig[@]}; do
key=$(echo ${item} | ${awkPath} -F '=' '{print $1}')
value=$(echo ${item} | ${awkPath} -F '=' '{print $2}')
if [ -n "$value" ]; then
if [ $debug == true ]; then
echo -e "::$LINENO) \033\e[32m Successful SET $key = ${value} \033[0m"
fi
fi
done
fi
}
function app_entry(){
setOptions $@
printOptions $@
source ${readShellPath}
createFiles
cacheNetworkInfo "${netWorkConfig[*]}"
}
app_entry $@
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。