diff options
Diffstat (limited to 'package/base-files')
-rwxr-xr-x | package/base-files/files/bin/config_generate | 16 | ||||
-rw-r--r-- | package/base-files/files/lib/functions/system.sh | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 3ca035ca8b..b473eba9e9 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -3,6 +3,7 @@ CFG=/etc/board.json . /usr/share/libubox/jshn.sh +. /lib/functions/system.sh [ -s $CFG ] || /bin/board_detect || exit 1 [ -s /etc/config/network -a -s /etc/config/system ] && exit 0 @@ -253,9 +254,22 @@ generate_static_system() { add_list system.ntp.server='3.openwrt.pool.ntp.org' EOF + local label_macaddr=$(get_mac_label_dt) + local hostname + + if json_is_a system object; then + json_select system + [ -n "$label_macaddr" ] || json_get_var label_macaddr label_macaddr + json_select .. + fi + + if [ -n "$label_macaddr" ]; then + hostname="OpenWrt-$(macaddr_geteui $label_macaddr)" + uci -q set "system.@system[-1].hostname=$hostname" + fi + 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 diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index be7efe4e2e..c4dc3cc3a9 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -144,6 +144,13 @@ macaddr_add() { echo $oui:$nic } +macaddr_geteui() { + local mac=$1 + local sep=$2 + + echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2} +} + macaddr_setbit_la() { local mac=$1 |