All pastes #2053487 Raw Edit

Mine

public text v1 · immutable
#2053487 ·published 2011-05-03 14:52 UTC
rendered paste body
#!/bin/sh

function fail() {
        echo $0 $* | logger
        exit 0
}

grep -qw 'method:nfs' /proc/cmdline || fail "No nfs told to propagator"

srv=$(grep -w '/image nfs' /proc/mounts | cut -d':' -f 1)
if [ -z $srv ]; then
        fail "I can't find address of NFS server in proc mounts: $(grep -w '/image' /proc/mounts)"
fi

iface=$(ip -o ro get $srv | egrep -ows 'dev [^ ]+' | cut -d' ' -f 2)
if [ -z $iface ]; then
        fail "$0 problem getting NFS iface for srv=$srv. ip ro output: $(ip -o ro get $srv 2>&1)"
fi

if [ -d /etc/net/ifaces/$iface ]; then
        fail "Interface directory for $iface already exist and i will not touch it"
fi

mkdir /etc/net/ifaces/$iface
cat << EOF > /etc/net/ifaces/$iface/options
NM_CONTROLLED=no
TYPE=eth
BOOTPROTO=static
ONBOOT=no
EOF