Commit 19d5dd74 authored by Adam Wujek's avatar Adam Wujek 💬

[Feature: 1388] Allow to specify hostname in the dot-config URL

Allow to specify hostname in the dot-config URL and in PPSI URL.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent be083eea
...@@ -40,8 +40,8 @@ config DOTCONF_URL ...@@ -40,8 +40,8 @@ config DOTCONF_URL
depends on DOTCONF_SOURCE_REMOTE depends on DOTCONF_SOURCE_REMOTE
help help
tftp://, ftp:// or http:// URLs are allowed. Names are allowed if tftp://, ftp:// or http:// URLs are allowed. Names are allowed if
you configured a DNS server. The special strings IPADDR and MACADDR you configured a DNS server. The special strings HOSTNAME, IPADDR and
are substituted before retrieving the file. MACADDR are substituted before retrieving the file.
Example: "tftp://morgana/wrs-config-IPADDR" Example: "tftp://morgana/wrs-config-IPADDR"
config BR2_CONFIGFILE config BR2_CONFIGFILE
...@@ -593,7 +593,7 @@ config PTP_CONF_URL ...@@ -593,7 +593,7 @@ config PTP_CONF_URL
depends on PTP_REMOTE_CONF depends on PTP_REMOTE_CONF
string "Download URL (http, ftp, tftp) for custom ppsi.conf" string "Download URL (http, ftp, tftp) for custom ppsi.conf"
help help
Like CONFIG_DOTCONF_URL, this option allows passing IPADDR Like CONFIG_DOTCONF_URL, this option allows passing HOSTNAME, IPADDR
and MACADDR in the filename, and if a DNS server is configured, and MACADDR in the filename, and if a DNS server is configured,
you can use host names. you can use host names.
For example: tftp://morgana/wrs-IPADDR-ppsi.conf For example: tftp://morgana/wrs-IPADDR-ppsi.conf
......
...@@ -403,8 +403,10 @@ file, it will replace the copy in the local storage if it is different. ...@@ -403,8 +403,10 @@ file, it will replace the copy in the local storage if it is different.
The URL (stored in @t{CONFIG_DOTCONF_URL} or retrieved via DHCP) is of the form The URL (stored in @t{CONFIG_DOTCONF_URL} or retrieved via DHCP) is of the form
``@i{protocol}@t{://}@i{host}@t{/}@i{pathname}''. The special upper-case ``@i{protocol}@t{://}@i{host}@t{/}@i{pathname}''. The special upper-case
strings @t{IPADDR} and @t{MACADDR} are substituted with the current strings @t{HOSTNAME}, @t{IPADDR} and @t{MACADDR} are substituted with the
addresses of the management port of the switch. current hostname, IP addresses or MAC address of the management port of the
switch. By this the same configuration string can be used to set up a batch
of switches with different configurations.
The three parts of the URL are as follows: The three parts of the URL are as follows:
...@@ -424,8 +426,8 @@ The three parts of the URL are as follows: ...@@ -424,8 +426,8 @@ The three parts of the URL are as follows:
@item path @item path
The pathname can include directory components and @t{IPADDR} The pathname can include directory components and any of @t{HOSTNAME},
or @t{MACADDR} (or both). @t{IPADDR}, @t{MACADDR}.
@end table @end table
...@@ -722,7 +724,8 @@ value is changed by the web interface, proper action is taken. ...@@ -722,7 +724,8 @@ value is changed by the web interface, proper action is taken.
Finally, you can choose @t{PTP_REMOTE_CONF} and be able to Finally, you can choose @t{PTP_REMOTE_CONF} and be able to
specify an URL (@t{http://}, @t{ftp://} or @t{tftp://}) whence specify an URL (@t{http://}, @t{ftp://} or @t{tftp://}) whence
the switch will download the @t{ppsi.conf} at boot time. the switch will download the @t{ppsi.conf} at boot time.
The filename in the URL can include @t{IPADDR} and/or @t{MACADDR}, The filename in the URL can include @t{HOSTNAME}, @t{IPADDR}
and/or @t{MACADDR},
so the same configuration string can be used to set up a batch so the same configuration string can be used to set up a batch
of switches with different configurations. of switches with different configurations.
......
...@@ -86,8 +86,9 @@ if [ "$CONFIG_DOTCONF_SOURCE_REMOTE" = "y" ] || [ "$CONFIG_DOTCONF_SOURCE_TRY_DH ...@@ -86,8 +86,9 @@ if [ "$CONFIG_DOTCONF_SOURCE_REMOTE" = "y" ] || [ "$CONFIG_DOTCONF_SOURCE_TRY_DH
/etc/init.d/network /etc/init.d/network
ipaddr=$(ifconfig eth0 | grep inet | cut -d: -f 2 | cut '-d ' -f 1) ipaddr=$(ifconfig eth0 | grep inet | cut -d: -f 2 | cut '-d ' -f 1)
fi fi
host_name=`hostname`
URL=$(echo $CONFIG_DOTCONF_URL | \ URL=$(echo $CONFIG_DOTCONF_URL | \
sed -e s/MACADDR/$macaddr/ -e s/IPADDR/$ipaddr/) sed -e s/MACADDR/$macaddr/ -e s/IPADDR/$ipaddr/ -e s/HOSTNAME/$host_name/)
# split the parts, as we need to handle tftp by hand # split the parts, as we need to handle tftp by hand
proto=$(echo $URL | cut -d: -f 1) proto=$(echo $URL | cut -d: -f 1)
host=$(echo $URL | cut -d/ -f 3) host=$(echo $URL | cut -d/ -f 3)
......
...@@ -116,8 +116,9 @@ elif [ "$CONFIG_PTP_REMOTE_CONF" = "y" ]; then ...@@ -116,8 +116,9 @@ elif [ "$CONFIG_PTP_REMOTE_CONF" = "y" ]; then
/etc/init.d/network /etc/init.d/network
ipaddr=$(ifconfig eth0 | grep inet | cut -d: -f 2 | cut '-d ' -f 1) ipaddr=$(ifconfig eth0 | grep inet | cut -d: -f 2 | cut '-d ' -f 1)
fi fi
host_name=`hostname`
URL=$(echo $CONFIG_PTP_CONF_URL | \ URL=$(echo $CONFIG_PTP_CONF_URL | \
sed -e s/MACADDR/$macaddr/ -e s/IPADDR/$ipaddr/) sed -e s/MACADDR/$macaddr/ -e s/IPADDR/$ipaddr/ -e s/HOSTNAME/$host_name/)
# split the parts, as we need to handle tftp by hand # split the parts, as we need to handle tftp by hand
proto=$(echo $URL | cut -d: -f 1) proto=$(echo $URL | cut -d: -f 1)
host=$(echo $URL | cut -d/ -f 3) host=$(echo $URL | cut -d/ -f 3)
......
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