The contents of my "/etc/conf.d/net" is shown below.
modules_eth0=( "dhclient" )
config_work=( "dhcp" )
config_home="192.168.1.254 netmask 255.255.255.0 brd 192.168.0.255"
routes_home="default via 192.168.1.1"
dns_servers_home="127.0.0.1 192.168.1.1"
cmdline_opt() {
if [ $# -ne 1 ] || ! [ -r /proc/cmdline ]; then
return 1
fi
for opt in $(cat /proc/cmdline) ; do
[ "${opt}" = "${1}" ] && return 0
done
return 1
}
preup() {
if [ "${IFACE}" = "eth0" ] ; then
if cmdline_opt location=home ; then
einfo "Setting network profile: home"
_configure_variables "home"
elif cmdline_opt location=work ; then
einfo "Setting network profile: work"
_configure_variables "work"
else
return 1
fi
fi
# Remember to return 0 on success
return 0
}
I pass "location" as kernel parameter when I boot the machine. So, I added it to the kernel boot line in "grub.conf". I choose the appropriate kernel to boot from the grub menu depending on whether I am at home or work. The relevant portions of my "grub.conf" is shown below.
title Gentoo Vanilla Sources (2.6.28-ab1) (Home)
root (hd0,4)
kernel /boot/kernel-genkernel-x86-2.6.28-ab1 ro real_root=/dev/sda5 location=home
title Gentoo Vanilla Sources (2.6.28-ab1) (Work)
root (hd0,4)
kernel /boot/kernel-genkernel-x86-2.6.28-ab1 ro real_root=/dev/sda5 location=work
If there are any easier/cleaner solutions I would like to hear about them.
No comments:
Post a Comment