优化固件 IP 地址修改
This commit is contained in:
parent
4a612127d9
commit
e6d2802108
|
@ -125,27 +125,34 @@ Firmware-Diy_Base() {
|
||||||
AddPackage git other luci-theme-argon https://github.com/jerrykuku 18.06
|
AddPackage git other luci-theme-argon https://github.com/jerrykuku 18.06
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
TIME "[ERROR] Unknown source branch: [${Current_Branch}] !"
|
TIME "[ERROR] Unknown Openwrt branch: [${Current_Branch}] !"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
New_IP_Address="{Default_IP_Address}"
|
||||||
if [[ -n "${Defined_IP_Address}" ]];then
|
if [[ -n "${Defined_IP_Address}" ]];then
|
||||||
TIME "Using defined IP Address [${Defined_IP_Address}] ..."
|
TIME "Using defined IP Address [${Defined_IP_Address}] ..."
|
||||||
Default_IP_Address="${Defined_IP_Address}"
|
New_IP_Address="${Defined_IP_Address}"
|
||||||
else
|
else
|
||||||
TIME "Using default IP Address [${Default_IP_Address}] ..."
|
TIME "Using default IP Address [${New_IP_Address}] ..."
|
||||||
fi
|
fi
|
||||||
[[ -n "${Default_IP_Address}" ]] && [[ "${Default_IP_Address}" != false ]] && {
|
[[ -n "${New_IP_Address}" ]] && [[ "${New_IP_Address}" != false ]] && {
|
||||||
if [[ "${Default_IP_Address}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]];then
|
if [[ "${New_IP_Address}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]];then
|
||||||
Old_IP_Address=$(awk -F '[="]+' '/ipaddr:-/{print $3}' package/base-files/files/bin/config_generate | awk 'NR==1')
|
Old_IP_Address=$(awk -F '[="]+' '/ipaddr:-/{print $3}' package/base-files/files/bin/config_generate | awk 'NR==1')
|
||||||
if [[ ! "${Default_IP_Address}" == "${Old_IP_Address}" ]];then
|
if [[ ! "${New_IP_Address}" == "${Old_IP_Address}" ]];then
|
||||||
TIME "Setting default IP Address to ${Default_IP_Address} ..."
|
TIME "Setting default IP Address to ${New_IP_Address} ..."
|
||||||
sed -i "s/${Old_IP_Address}/${Default_IP_Address}/g" package/base-files/files/bin/config_generate
|
sed -i "s/${Old_IP_Address}/${New_IP_Address}/g" package/base-files/files/bin/config_generate
|
||||||
|
a=$(echo ${Old_IP_Address} | egrep -o "[0-9]+.[0-9]+.")
|
||||||
|
b=$(echo ${New_IP_Address} | egrep -o "[0-9]+.[0-9]+.")
|
||||||
|
c="$(egrep -o ")).[0-9]+" package/base-files/files/bin/config_generate)"
|
||||||
|
d=")).$(echo ${New_IP_Address} | egrep -o "[0-9]+" | awk 'END {print}')"
|
||||||
|
sed -i "s/${a}/${b}/g" package/base-files/files/bin/config_generate
|
||||||
|
sed -i "s/${c}/${d}/g" package/base-files/files/bin/config_generate
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
TIME "[ERROR] ${Default_IP_Address} is not an IP Address !"
|
TIME "[ERROR] ${New_IP_Address} is not an IP Address !"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
[ -f package/base-files/files/bin/AutoUpdate.sh ] && {
|
[ -f package/base-files/files/bin/AutoUpdate.sh ] && {
|
||||||
|
|
Loading…
Reference in New Issue