sonic-buildimage/files/initramfs-tools/mgmt-intf-dhcp

37 lines
887 B
Plaintext
Raw Normal View History

#!/bin/sh
PREREQS="union-mount"
prereqs() { echo "$PREREQS"; }
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
case "$x" in
mgmt-intf-dhcp=*)
val="${x#mgmt-intf-dhcp=}"
if [ -z "$val" ]; then
echo "ERROR: mgmt-intf-dhcp value (on/off) not specified !"
exit 0
fi
if [ -e "${rootmnt}/etc/network/interfaces" ]; then
if [ "$val" = "off" ]; then
sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' ${rootmnt}/etc/network/interfaces
elif [ "$val" = "on" ]; then
sed -i 's/iface eth0 inet static/iface eth0 inet dhcp/g' ${rootmnt}/etc/network/interfaces
fi
fi
;;
esac
done