Commit 62b3ba79 authored by Adam Wujek's avatar Adam Wujek 💬

rootfs: add IP configuration of management port to Kconfig

--Update /etc/init.d/network script.
Keeping lo up prevents monit from restarting dropbear and lighttpd,
then finally rebooting system due to exceeded number of maximum application's
restarts.
--keep lo ocnfiguration in /etc/network/interfaces due to above
--Update user manual
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 1f2a404f
......@@ -35,6 +35,69 @@ config PPSI
menu "Local Network Configuration"
choice
prompt "Management port configuration (eth0)"
default ETH0_DHCP
config ETH0_DHCP
bool "DHCP forever"
help
Try DHCP on management port (eth0) forever.
config ETH0_DHCP_ONCE
bool "Try DHCP, if fail use static address"
help
Try DHCP on management port (eth0) for a while, then configure
static IP. Useful, when you move switch between various development
enviroments.
config ETH0_STATIC
bool "Static address"
help
Use static address on management port (eth0). Don't try to DHCP.
endchoice
menu "Management port (eth0) Address"
depends on ETH0_DHCP_ONCE || ETH0_STATIC
config ETH0_IP
string "Static IP address of management port (eth0)"
default "192.168.1.254"
help
Static IP address of management port (eth0). Please note that
wrong IP address will generate a runtime error on the switch.
config ETH0_MASK
string "Mask of management port (eth0)"
default "255.255.255.0"
help
Mask of management port (eth0). Please note that wrong mask will
generate a runtime error on the switch.
config ETH0_NETWORK
string "Network of management port (eth0)"
default "192.168.1.0"
help
Network of management port (eth0). Please note that wrong network
will generate a runtime error on the switch.
config ETH0_BROADCAST
string "Broadcast of management port (eth0)"
default "192.168.1.255"
help
Broadcast of management port (eth0). Please note that wrong broadcast
will generate a runtime error on the switch.
config ETH0_GATEWAY
string "Default gateway of management port (eth0)"
default "192.168.1.1"
help
Default gateway of management port (eth0). Please note that
wrong gateway address will generate a runtime error on the switch.
endmenu
config NTP_SERVER
string "IP address of local NTP server (empty for none)"
help
......
......@@ -431,6 +431,25 @@ value is changed by the web interface, proper action is taken.
the next time the system boots. See @ref{Dynamic WRS Configuration}
and @ref{The Configuration File} for details.
@item CONFIG_ETH0_DHCP
@itemx CONFIG_ETH0_DHCP_ONCE
@itemx CONFIG_ETH0_STATIC
Configuration of management port's (@t{eth0}) IP. When
@t{CONFIG_ETH0_DHCP} is used, then switch tries to obtain IP via DHCP
forever. For option @t{CONFIG_ETH0_DHCP_ONCE} switch tries to get IP
via DHCP once, if this try is unsuccessful then switch uses static IP.
@t{CONFIG_ETH0_STATIC} forces switch to use provided static IP address.
@item CONFIG_ETH0_IP
@itemx CONFIG_ETH0_MASK
@itemx CONFIG_ETH0_NETWORK
@itemx CONFIG_ETH0_BROADCAST
@itemx CONFIG_ETH0_GATEWAY
Management port's (@t{eth0}) static IP configuration when
@t{CONFIG_ETH0_DHCP_ONCE} or @t{CONFIG_ETH0_STATIC} parameter is used.
@item CONFIG_NTP_SERVER
The NTP server used to prime White Rabbit time, at system boot.
......
......@@ -3,15 +3,72 @@
# Start the network....
#
dotconfig=/wr/etc/dot-config
int_file=/etc/network/interfaces
# no matter what we do keep lo up
ifup lo &> /dev/null
if grep -q '/ nfs' /proc/mounts; then
echo "Running via NFS: leaving eth0 config alone"
exit 0
fi
if grep -v '#' /etc/network/interfaces | grep -q 'eth0.*dhcp'; then
# run dhcp client in background, as ifup would run in one-shot mode
udhcpc -b -i eth0
else
# read dot-config
if [ -f $dotconfig ]; then
. $dotconfig
fi
# kill all previous instances of udhcpc
killall udhcpc &> /dev/null
# put eth0 down in case it was up before
ifdown eth0 &> /dev/null
if [ "$CONFIG_ETH0_STATIC" ] || [ "$CONFIG_ETH0_DHCP_ONCE" ]; then
echo "Write IP address"
echo "# File generated from dot-config, do not edit!" > $int_file
echo "# Configure Loopback" >> $int_file
echo "auto lo" >> $int_file
echo "iface lo inet loopback" >> $int_file
echo "" >> $int_file
echo "iface eth0 inet static" >> $int_file
if [ "$CONFIG_ETH0_IP" ]; then
echo " address $CONFIG_ETH0_IP" >> $int_file
fi
if [ "$CONFIG_ETH0_MASK" ]; then
echo " netmask $CONFIG_ETH0_MASK" >> $int_file
fi
if [ "$CONFIG_ETH0_NETWORK" ]; then
echo " network $CONFIG_ETH0_NETWORK" >> $int_file
fi
if [ "$CONFIG_ETH0_BROADCAST" ]; then
echo " broadcast $CONFIG_ETH0_BROADCAST" >> $int_file
fi
if [ "$CONFIG_ETH0_GATEWAY" ]; then
echo " gateway $CONFIG_ETH0_GATEWAY" >> $int_file
fi
fi
if [ "$CONFIG_ETH0_DHCP_ONCE" ]; then
echo "Try DHCP to get IP"
# try dhcp, if fail use static IP
udhcpc -i eth0 -n
if [ $? -ne 0 ]; then
echo "Failed to obtain IP address via DHCP, set static IP"
CONFIG_ETH0_STATIC="y"
fi
fi
if [ "$CONFIG_ETH0_STATIC" ]; then
# ifup to use static parameters from /etc/netwrok/interfaces
echo "Using static IP"
ifup eth0
fi
if [ "$CONFIG_ETH0_DHCP" ]; then
# try to get IP via dhcp if failed run dhcp client forever in background
echo "Using DHCP to get IP"
udhcpc -b -i eth0
fi
# This file will be overwritten in run time by /etc/init.c/network
#
# Configure Loopback
auto lo
iface lo inet loopback
#Force eth0 to be configured by DHCP
auto eth0
iface eth0 inet dhcp
# Uncomment this example for static configuration
# iface eth0 inet static
# address 192.168.1.10
# netmask 255.255.255.0
# network 192.168.1.0
# broadcast 192.168.1.255
# gateway 192.168.1.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment