feat(zbm): In Syslinux/extlinux mode add KCL (#6)
This commit is contained in:
parent
119be2b876
commit
a2cb784cb3
31
setup.sh
31
setup.sh
@ -832,8 +832,31 @@ function customize_dropbear_hooks () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_unique_ip_in_syslinux_kcl () {
|
||||||
|
local zbm_config default_ip
|
||||||
|
zbm_config="${1:?}"
|
||||||
|
default_ip="${2:?}"
|
||||||
|
|
||||||
|
# First -e expression removes first looks for lines that contain
|
||||||
|
# 'APPEND' plus a space character and only in those lines removes all
|
||||||
|
# occurrences of ' ip=' followed by as many non-space characters as
|
||||||
|
# possible. This removes whatever 'ip=' definition already was present.
|
||||||
|
#
|
||||||
|
# Second -e expression similarly looks for lines that contain 'APPEND'
|
||||||
|
# plus a space character then at their end inserts a space plus our
|
||||||
|
# desired new 'ip=' definition. This puts in place the 'ip=' we want.
|
||||||
|
sed -ri \
|
||||||
|
-e \\$'\x1''APPEND '$'\x1 s'$'\x1'' ip=([^[:space:]]*)'$'\x1'''$'\x1''gi' \
|
||||||
|
-e \\$'\x1''APPEND '$'\x1 s'$'\x1''$'$'\x1'' '"${default_ip}"''$'\x1''gi' \
|
||||||
|
"${zbm_config}"
|
||||||
|
}
|
||||||
|
|
||||||
function ensure_ip_in_kcl () {
|
function ensure_ip_in_kcl () {
|
||||||
local zbm_config kcl_length kcl_string default_ip ip_addr_found new_kcl first_kcl_elem
|
local default_ip
|
||||||
|
default_ip='ip='"${ARCHZBM_NET_CLIENT_IP}"':'"${ARCHZBM_NET_SERVER_IP}"':'"${ARCHZBM_NET_GATEWAY_IP}"':'"${ARCHZBM_NET_NETMASK}"':'"${ARCHZBM_NET_HOSTNAME}"':'"${ARCHZBM_NET_DEVICE}"':'"${ARCHZBM_NET_AUTOCONF}"
|
||||||
|
|
||||||
|
if [[ "${part_schema}" = 'gpt' ]]; then
|
||||||
|
local zbm_config kcl_length kcl_string ip_addr_found new_kcl first_kcl_elem
|
||||||
local -a kcl
|
local -a kcl
|
||||||
paru_install 'go-yq'
|
paru_install 'go-yq'
|
||||||
|
|
||||||
@ -847,7 +870,6 @@ function ensure_ip_in_kcl () {
|
|||||||
kcl_string="$(yq '.Kernel.CommandLine' "${zbm_config}")"
|
kcl_string="$(yq '.Kernel.CommandLine' "${zbm_config}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
default_ip='ip='"${ARCHZBM_NET_CLIENT_IP}"':'"${ARCHZBM_NET_SERVER_IP}"':'"${ARCHZBM_NET_GATEWAY_IP}"':'"${ARCHZBM_NET_NETMASK}"':'"${ARCHZBM_NET_HOSTNAME}"':'"${ARCHZBM_NET_DEVICE}"':'"${ARCHZBM_NET_AUTOCONF}"
|
|
||||||
mapfile -t kcl < <(<<<"${kcl_string}" tr ' ' '\n' | sed '/^$/d')
|
mapfile -t kcl < <(<<<"${kcl_string}" tr ' ' '\n' | sed '/^$/d')
|
||||||
for kcl_elem in "${!kcl[@]}"; do
|
for kcl_elem in "${!kcl[@]}"; do
|
||||||
if grep -Piq -- 'ip=' <<<"${kcl[$kcl_elem]}"; then
|
if grep -Piq -- 'ip=' <<<"${kcl[$kcl_elem]}"; then
|
||||||
@ -869,6 +891,11 @@ function ensure_ip_in_kcl () {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
yq -i '.Kernel.CommandLine = "'"${new_kcl}"'"' "${zbm_config}"
|
yq -i '.Kernel.CommandLine = "'"${new_kcl}"'"' "${zbm_config}"
|
||||||
|
else
|
||||||
|
local zbm_config
|
||||||
|
zbm_config='/boot/syslinux/syslinux.cfg'
|
||||||
|
set_unique_ip_in_syslinux_kcl "${zbm_config}" "${default_ip}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_pub_keys () {
|
function set_pub_keys () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user