From da813e5b9ded288764708b651b24a8be08cd9629 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Tue, 15 Nov 2011 22:28:53 -0300 Subject: [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 --- archiso/hooks/archiso_pxe_nbd | 50 +++++++++---------------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) (limited to 'archiso/hooks/archiso_pxe_nbd') diff --git a/archiso/hooks/archiso_pxe_nbd b/archiso/hooks/archiso_pxe_nbd index cdf4392..be3db28 100644 --- a/archiso/hooks/archiso_pxe_nbd +++ b/archiso/hooks/archiso_pxe_nbd @@ -1,8 +1,12 @@ # vim: set ft=sh: run_hook () { - local line i net_mac bootif_mac bootif_dev address netmask gateway dns0 dns1 rootserver rootpath filename - - : > /ip_opts + local line i net_mac bootif_mac bootif_dev + # These variables will be parsed from /tmp/net-*.conf generated by ipconfig + 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 "${BOOTIF}" ]; then @@ -20,45 +24,11 @@ run_hook () { fi # setup network and save some values - ipconfig "ip=${ip}" | while read line; do - # 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 + ipconfig "ip=${ip}" - echo "IP-Config: ${address}/${netmask}" - echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}" + . /tmp/net-*.conf - nbdserver=${rootserver} + nbdserver=${ROOTSERVER} [[ -z "${archiso_nbd_name}" ]] && archiso_nbd_name="archiso" -- cgit v1.2.3-70-g09d2