summaryrefslogtreecommitdiffstats
path: root/hooks/net
diff options
context:
space:
mode:
authorSimon Boulay <simon.boulay@gmail.com>2010-02-08 19:44:53 +0100
committerThomas Bächler <thomas@archlinux.org>2010-02-09 20:28:05 +0100
commit82e9837b9661ead8f78023ef645c7b6679786739 (patch)
tree56e34875aab4ee172ec18c55b56e17402f9309b6 /hooks/net
parent7d99fdb862b10e9019e5be78ad7afb6c1ae7f8c0 (diff)
downloadmkinitcpio-82e9837b9661ead8f78023ef645c7b6679786739.tar.gz
mkinitcpio-82e9837b9661ead8f78023ef645c7b6679786739.tar.xz
Add support for mounting root filesystem over NFS.
Diffstat (limited to 'hooks/net')
-rw-r--r--hooks/net72
1 files changed, 72 insertions, 0 deletions
diff --git a/hooks/net b/hooks/net
new file mode 100644
index 0000000..9b97e39
--- /dev/null
+++ b/hooks/net
@@ -0,0 +1,72 @@
+# vim: set ft=sh:
+run_hook ()
+{
+ local line i address rootserver rootpath
+
+ : > /ip_opts
+
+ if [ -n "${ip}" ]; then
+ # setup network and save some values
+ ipconfig "${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
+
+ echo "IP-Config: ${address}/${netmask}"
+ echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}"
+
+ # calculate nfs_server, nfs_path and nfs_option for later nfs mount
+ if [ "${root}" = "/dev/nfs" -o "${nfsroot}" != "" ]; then
+ # default rootpath
+ if [ "${rootpath}" = "" ]; then
+ rootpath="/tftpboot/${address}"
+ fi
+
+ # parse nfsroot
+ line="${nfsroot}"
+ nfs_server="${line%%:*}"
+ [ "${nfs_server}" = "${line}" ] && nfs_server="${rootserver}"
+ line="${line#*:}"
+ nfs_path="${line%%,*}"
+ line="${line#"${nfs_path}"}"
+ [ "${nfs_path}" = "" ] && nfs_path="${rootpath}"
+ nfs_option="${line#","}"
+
+ # ensure root and filesystem type are set proper for nfs boot
+ root="/dev/nfs"
+ rootfstype="nfs"
+
+ echo "NFS-root: ${nfs_server}:${nfs_path}"
+ fi
+ fi
+}