mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-11 15:33:03 +00:00
x86: preinit: make name rewrite into reusable function
There might be other places (such as vendor-supplied preinit scripts) where we wish to take a DMI name and clean it up in a consistent way, so make the sed command into a function. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
This commit is contained in:
parent
6c76decd61
commit
445f980a38
@ -1,3 +1,12 @@
|
|||||||
|
sanitize_name_x86() {
|
||||||
|
sed -e '
|
||||||
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
||||||
|
s/[^a-z0-9_-]\+/-/g;
|
||||||
|
s/^-//;
|
||||||
|
s/-$//;
|
||||||
|
' "$@"
|
||||||
|
}
|
||||||
|
|
||||||
do_sysinfo_x86() {
|
do_sysinfo_x86() {
|
||||||
local vendor product file
|
local vendor product file
|
||||||
|
|
||||||
@ -17,12 +26,7 @@ do_sysinfo_x86() {
|
|||||||
|
|
||||||
echo "$vendor $product" > /tmp/sysinfo/model
|
echo "$vendor $product" > /tmp/sysinfo/model
|
||||||
|
|
||||||
sed -e '
|
sanitize_name_x86 /tmp/sysinfo/model > /tmp/sysinfo/board_name
|
||||||
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
|
||||||
s/[^a-z0-9_-]\+/-/g;
|
|
||||||
s/^-//;
|
|
||||||
s/-$//;
|
|
||||||
' /tmp/sysinfo/model > /tmp/sysinfo/board_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_hook_add preinit_main do_sysinfo_x86
|
boot_hook_add preinit_main do_sysinfo_x86
|
||||||
|
Loading…
Reference in New Issue
Block a user