Message ID | 20181204014126.29006-1-zhouyousong@yunionyun.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,v2] ovs-ctl: fallback to "uname -n" for fetching hostname | expand |
On Tue, Dec 04, 2018 at 01:41:26AM +0000, Yousong Zhou wrote: > From: Yousong Zhou <yszhou4tech@gmail.com> > > 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> > --- > v2 <- v1: fallback to "uname -n" when FULL_HOSTNAME=yes. Suggested by blp Thanks, applied to master.
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" }