summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2018-12-04 01:41:26 +0000
committerBen Pfaff <blp@ovn.org>2018-12-03 18:14:45 -0800
commitdd091e163e4d4b92cde2e60858078d5963c17e06 (patch)
tree18691d9bfcceace81364dad6f572d434ea037575 /utilities
parent4d1ca7035df8d1688b7d85e6495722f57870726f (diff)
downloadopenvswitch-dd091e163e4d4b92cde2e60858078d5963c17e06.tar.gz
ovs-ctl: fallback to "uname -n" for fetching hostname
The command "hostname" is not available in OpenWrt by default. Strace result of hostname-3.13 on centos7 shows that bare "hostname" command calls uname() to fetch node name. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ctl.in7
1 files changed, 4 insertions, 3 deletions
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index e42f0f1e6..c92b270b9 100644
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -38,9 +38,10 @@ insert_mod_if_required () {
set_hostname () {
# 'hostname -f' needs network connectivity to work. So we should
# call this only after ovs-vswitchd is running.
- hn="$(hostname -f)"
- if test X$FULL_HOSTNAME = Xno; then
- hn="$(hostname)"
+ if test X$FULL_HOSTNAME = Xyes; then
+ hn="$(hostname -f)" || hn="$(uname -n)"
+ else
+ hn="$(uname -n)"
fi
ovs_vsctl set Open_vSwitch . external-ids:hostname="$hn"
}