Commit 33df5835 authored by Adam Wujek's avatar Adam Wujek 💬

Kconfig: add configuration for setting up hostname

Hostname can be configured in dot-config to be set via DHCP or statically.

Additionally update documentation.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent e325525b
......@@ -127,6 +127,29 @@ config ETH0_GATEWAY
endmenu
choice
prompt "Hostname source"
default HOSTNAME_DHCP
config HOSTNAME_DHCP
bool "Get hostname via DHCP"
help
Get hostname from DHCP server.
config HOSTNAME_STATIC
bool "Use static hostname"
help
Use static Hostname stored in CONFIG_HOSTNAME_STRING
endchoice
config HOSTNAME_STRING
string "Static hostname of the switch"
default "wrs"
depends on HOSTNAME_STATIC
help
Use this string as a static hostname of the switch.
menu "Root Password"
config ROOT_PWD_IS_ENCRYPTED
......
......@@ -504,6 +504,14 @@ value is changed by the web interface, proper action is taken.
Management port's (@t{eth0}) static IP configuration when
@t{CONFIG_ETH0_DHCP_ONCE} or @t{CONFIG_ETH0_STATIC} parameter is used.
@item CONFIG_HOSTNAME_DHCP
@itemx CONFIG_HOSTNAME_STATIC
@itemx CONFIG_HOSTNAME_STRING
These options describe how to set hostname of the switch. From DHCP
(@t{CONFIG_HOSTNAME_DHCP}) or use a predefined value
(@t{CONFIG_HOSTNAME_STATIC}) defined in option @t{CONFIG_HOSTNAME_STRING}.
@item CONFIG_ROOT_PWD_IS_ENCRYPTED
@itemx CONFIG_ROOT_PWD_CLEAR
@itemx CONFIG_ROOT_PWD_CYPHER
......
......@@ -58,10 +58,17 @@ if [ "$CONFIG_ETH0_STATIC" = "y" ] || [ "$CONFIG_ETH0_DHCP_ONCE" = "y" ]; then
fi
if [ "$CONFIG_HOSTNAME_STATIC" = "y" ]; then
/bin/hostname "$CONFIG_HOSTNAME_STRING"
echo "$CONFIG_HOSTNAME_STRING" > /etc/hostname
elif [ "$CONFIG_HOSTNAME_DHCP" = "y" ]; then
DHCP_OPT_EXTRA="-O hostname -s /wr/bin/dhcp_extra_opt.sh"
fi
if [ "$CONFIG_ETH0_DHCP_ONCE" = "y" ]; then
echo "Try DHCP to get IP"
# try dhcp, if fail use static IP
udhcpc -i eth0 -n
udhcpc -i eth0 -n $DHCP_OPT_EXTRA
if [ $? -ne 0 ]; then
echo "Failed to obtain IP address via DHCP, set static IP"
CONFIG_ETH0_STATIC="y"
......@@ -80,4 +87,4 @@ fi
# Try to get IP via dhcp if failed run dhcp client forever in background.
# If no information how to get IP address is available use this option.
echo "Using DHCP to get IP"
udhcpc -b -i eth0
udhcpc -b -i eth0 $DHCP_OPT_EXTRA
#!/bin/sh
# Adam Wujek @ CERN
#
# This script is to be run by udhcpc
#
# udhcpc should get hostname the from DHCP server.
#
# check whether we got hostname from DHCP server
if [ -n "$hostname" ]; then
/bin/hostname "$hostname"
echo "$hostname" > /etc/hostname
fi
# call default script
source /usr/share/udhcpc/default.script
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