1. 程式人生 > >openwrt配置檔案的疑惑

openwrt配置檔案的疑惑

package/base-files/files/etc/config目錄

target/linux/ramips/base-files/etc/config目錄

這兩個目錄下的配置檔案是如何整合到最終生成的系統中的?

遇到一個問題,system這個配置檔案。

在target/linux/ramips/base-files/etc/config下新增system後,導致package/base-files/files/etc/config中內容

config system
    option hostname    OpenWrt
    option timezone    UTC

config timeserver ntp
    list server    0.openwrt.pool.ntp.org
    list server    1.openwrt.pool.ntp.org
    list server    2.openwrt.pool.ntp.org
    list server    3.openwrt.pool.ntp.org
    option enabled 1
    option enable_server 0

不會出現在最終的系統中,一個後果是在luci配置介面System->System Pro[erties中顯示

This section contains no values yet.

從而無法修改主機名和介面語言(中文,英文,等等)。

ssh登入後修改/etc/config/system新增上述內容後,在luci配置介面就出現了相應的選項。

在target/linux/ramips/base-files/etc/config目錄下新增其他檔案似乎為影響到package/base-files/files/etc/config目錄下的同名檔案,結果是二者合併的效果,若有相同選項,則target下覆蓋package下。為何system不生效?推測可能不生效的部分在生成最終系統是沒有其他指令碼對他進行操作。

恩山論壇兩位壇友解釋如下:

981213:

openwrt大部分基礎檔案都在軟體包base-files裡面。這個軟體包做3件事:
1 複製package/base-files/files下的所有檔案到根目錄
2 複製target/linux/對應平臺/base-files下的所有檔案到根目錄
3 複製原始碼根目錄下的files資料夾下的所有檔案到根目錄(如果需要新增自己的檔案那麼可以通過這一步,即在原始碼根目錄內新建一個files資料夾)

LazyZhu:

https://dev.openwrt.org/browser/ ... -files/Makefile#L85
注意優先級別,後面的檔案會覆蓋前面同名檔案
你的解決方法是 package/base-files/files/etc/config/system 內容全部移到 target/linux/ramips/base-files/etc/config/system 或者直接在 package/base-files/files/etc/config/system 中修改

981213:

配置檔案並不是純粹由檔案組成的。還有uci-defaults會新增別的配置。參見target/linux/對應平臺/base-files/etc/uci-defaults。

小結:config按優先順序覆蓋,然後uci-defaults在系統初始化時設定和調整引數,感覺合併的地方就是執行時的設定。