summaryrefslogtreecommitdiffstats
path: root/hooks/net
diff options
context:
space:
mode:
authorGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2011-11-16 02:14:51 +0100
committerDave Reisner <dreisner@archlinux.org>2011-11-29 11:56:41 +0100
commit1021e6ef1a21dc9b5cbbc238fd2e94db8789ea0d (patch)
treed9b6672f8c3f6f3e3d935404af5d1223cd3756f4 /hooks/net
parent79d406e5d4bba7cd056cf34e39cdfeac6e75c5de (diff)
downloadmkinitcpio-1021e6ef1a21dc9b5cbbc238fd2e94db8789ea0d.tar.gz
mkinitcpio-1021e6ef1a21dc9b5cbbc238fd2e94db8789ea0d.tar.xz
hooks/net: Refactor and remove sed cmd 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. * Add /tmp as part of "base" layout since this can be used by others hooks/cmds. Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Diffstat (limited to 'hooks/net')
-rw-r--r--hooks/net64
1 files changed, 17 insertions, 47 deletions
diff --git a/hooks/net b/hooks/net
index 24c08f8..b964d13 100644
--- a/hooks/net
+++ b/hooks/net
@@ -1,9 +1,13 @@
# vim: set ft=sh:
run_hook ()
{
- local line i address netmask gateway dns0 dns1 rootserver rootpath defaultrootpath defaultserver
-
- : > /ip_opts
+ local line defaultrootpath defaultserver
+ # 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 [ -z "${ip}" -a -n "${nfsaddrs}" ]; then
ip="${nfsaddrs}"
@@ -11,63 +15,29 @@ run_hook ()
if [ -n "${ip}" ]; then
# 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
# calculate nfs_server, nfs_path and nfs_option for later nfs mount
if [ "${root}" = "/dev/nfs" -o "${nfsroot}" != "" ]; then
- # parse rootpath if defined by dhcp server
- if [ -n "${rootpath}" ]; then
- line="${rootpath}"
+ # parse ROOTPATH if defined by dhcp server
+ if [ -n "${ROOTPATH}" ]; then
+ line="${ROOTPATH}"
nfs_server="${line%%:*}"
- [ "${nfs_server}" = "${line}" ] && nfs_server="${rootserver}"
+ [ "${nfs_server}" = "${line}" ] && nfs_server="${ROOTSERVER}"
defaultserver="${nfs_server}"
line="${line#*:}"
nfs_path="${line}"
defaultrootpath="${nfs_path}"
else
- # define a default rootpath
- if [ "${rootpath}" = "" ]; then
- defaultrootpath="/tftpboot/${address}"
+ # define a default ROOTPATH
+ if [ "${ROOTPATH}" = "" ]; then
+ defaultrootpath="/tftpboot/${IPV4ADDR}"
fi
fi
- # parse nfsroot if present (overrides rootpath)
+ # parse nfsroot if present (overrides ROOTPATH)
if [ -n "${nfsroot}" ]; then
line="${nfsroot}"
nfs_server="${line%%:*}"