OpenWRT编译时修改时区与主机名
网上搜的时候,都是显示的很古老的版本,文章基本来源于2013-2015年
告诉你修改主机名,设定时区
修改package/base-files/files/etc/config/system
其实不行,打开源码的话,etc下根本就没有config,更不要说system了
针对版本:LEDE 17.01(内核:4.4.198)
修改文件package/base-files/files/bin/config_generate
修改位置参照注释
generate_static_system() {
uci -q batch <<-EOF
delete system.@system[0]
add system system
set system.@system[-1].hostname='LEDE' # 主机名修改这里
set system.@system[-1].timezone='CST-8' # 时区修改这里就好了,原来这里是UTC
set system.@system[-1].ttylogin='0'
set system.@system[-1].log_size='64'
set system.@system[-1].urandom_seed='0'
delete system.ntp
set system.ntp='timeserver'
set system.ntp.enabled='1'
set system.ntp.enable_server='0'
add_list system.ntp.server='0.lede.pool.ntp.org'
add_list system.ntp.server='1.lede.pool.ntp.org'
add_list system.ntp.server='2.lede.pool.ntp.org'
add_list system.ntp.server='3.lede.pool.ntp.org'
EOF
if json_is_a system object; then
json_select system
local hostname
if json_get_var hostname hostname; then
uci -q set "system.@system[-1].hostname=$hostname"
fi
if json_is_a ntpserver array; then
local keys key
json_get_keys keys ntpserver
json_select ntpserver
uci -q delete "system.ntp.server"
for key in $keys; do
local server
if json_get_var server "$key"; then
uci -q add_list "system.ntp.server=$server"
fi
done
json_select ..
fi
json_select ..
fi
}