[hooks/archiso_pxe_nbd] Refactor, remove sed usage.
* ipconfig cmd writes a file in /tmp that is ready for direct evaluation. We can use this instead of parsing the output, to do this some variable renames are needed. Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
parent
7ab83b8571
commit
da813e5b9d
2 changed files with 12 additions and 40 deletions
|
@ -1,8 +1,12 @@
|
||||||
# vim: set ft=sh:
|
# vim: set ft=sh:
|
||||||
run_hook () {
|
run_hook () {
|
||||||
local line i net_mac bootif_mac bootif_dev address netmask gateway dns0 dns1 rootserver rootpath filename
|
local line i net_mac bootif_mac bootif_dev
|
||||||
|
# These variables will be parsed from /tmp/net-*.conf generated by ipconfig
|
||||||
: > /ip_opts
|
local DEVICE
|
||||||
|
local IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1
|
||||||
|
local HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH
|
||||||
|
local filename
|
||||||
|
# /tmp/net-*.conf
|
||||||
|
|
||||||
if [ -n "${ip}" ]; then
|
if [ -n "${ip}" ]; then
|
||||||
if [ -n "${BOOTIF}" ]; then
|
if [ -n "${BOOTIF}" ]; then
|
||||||
|
@ -20,45 +24,11 @@ run_hook () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# setup network and save some values
|
# setup network and save some values
|
||||||
ipconfig "ip=${ip}" | while read line; do
|
ipconfig "ip=${ip}"
|
||||||
# echo ":: ${line}"
|
|
||||||
if [ "${line#"IP-Config:"}" != "${line}" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
line="$(echo ${line} | sed -e 's/ :/:/g;s/: /=/g')"
|
|
||||||
for i in ${line}; do
|
|
||||||
case "${i}" in
|
|
||||||
address=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
netmask=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
gateway=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
dns0=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
dns1=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
rootserver=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
rootpath=*)
|
|
||||||
echo "${i}" >> /ip_opts
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
. /ip_opts
|
. /tmp/net-*.conf
|
||||||
|
|
||||||
echo "IP-Config: ${address}/${netmask}"
|
nbdserver=${ROOTSERVER}
|
||||||
echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}"
|
|
||||||
|
|
||||||
nbdserver=${rootserver}
|
|
||||||
|
|
||||||
[[ -z "${archiso_nbd_name}" ]] && archiso_nbd_name="archiso"
|
[[ -z "${archiso_nbd_name}" ]] && archiso_nbd_name="archiso"
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ build ()
|
||||||
FILES=""
|
FILES=""
|
||||||
SCRIPT="archiso_pxe_nbd"
|
SCRIPT="archiso_pxe_nbd"
|
||||||
|
|
||||||
|
add_dir /tmp
|
||||||
|
|
||||||
add_binary "/usr/sbin/nbd-client" "/bin/nbd-client"
|
add_binary "/usr/sbin/nbd-client" "/bin/nbd-client"
|
||||||
add_binary "/lib/initcpio/ipconfig" "/bin/ipconfig"
|
add_binary "/lib/initcpio/ipconfig" "/bin/ipconfig"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue