summaryrefslogtreecommitdiffstats
path: root/hooks/net
diff options
context:
space:
mode:
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%%:*}"