Skip to contentSkip to conversation

infiniband-diags: Remove Red Hat-ism.

PATCH In review Jon Stanley 4 participants 8 messages Dec 3, 2012 – Feb 13, 2013 5 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband-diags: Remove Red Hat-ism.

Future release of Fedora are going to remove /etc/sysconfig/network which we source to get $HOSTNAME. Bash (and sh) set $HOSTNAME in the shell by default, so we should be safe to use that here. This adds the benefit of working across multiple distributions if that is required in the future.

Related: rhbz881917

Cc Doug Ledford <[email protected]>
Cc Ira Weiny <[email protected]>
---
 scripts/set_nodedesc.sh |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
scripts/set_nodedesc.sh +0 -3
index 1e42ac8..3d2e406 100755
@@ -1,8 +1,5 @@
 #!/bin/sh
 
-if [ -f /etc/sysconfig/network ]; then
-. /etc/sysconfig/network
-fi
 
 ib_sysfs="/sys/class/infiniband"
 newname="$HOSTNAME"
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1354566498-8364-1-git-send-email-jonstanley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 5 lines · Jon Stanley

Future release of Fedora are going to remove /etc/sysconfig/network which we source to get $HOSTNAME. Bash (and sh) set $HOSTNAME in the shell by default, so we should be safe to use that here. This adds the benefit of working across multiple distributions if that is required in the future.

This looks like it is a bashism (ie dash does not do this), so you should update the #! to use /bin/bash not /bin/sh...

$ HOSTNAME= /bin/dash 
\h{\u}\w#echo $HOSTNAME

\h{\u}\w#

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20121203223547.GA3410-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#4 lore raw
Quoted 2 lines · Jason Gunthorpe

This looks like it is a bashism (ie dash does not do this), so you should update the #! to use /bin/bash not /bin/sh...

But Garrett just committed something a few days ago to remove bash-isms, and I'd hate to reintroduce one for this trivial thing. More specifically, here's what's going to happen in Fedora-land, and isn't in RHEL6:

The /etc/sysconfig/network file goes away, and is replaced (for our purposes) with /etc/hostname ,which contains the short name of the hostname. The way I figure it, we can get the hostname one of a few ways here:

1) Blindly trust that the set hostname is correct (i.e. what the hostname(1) command returns is what we should be using)
2) Read /etc/hostname in a subshell (the HOSTNAME= no longer exists, so it can't be sourced)
3) Fall back on /etc/sysconfig/network if we don't find /etc/hostname if we go with 2.

Thoughts?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CALY6xnj_OYpQFiCSC4T3cY3yup6ZXXJR=QDDCaJN96gEyvFP5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 16 lines · Jon Stanley
Quoted 2 lines · Jason Gunthorpe

This looks like it is a bashism (ie dash does not do this), so you should update the #! to use /bin/bash not /bin/sh...

But Garrett just committed something a few days ago to remove bash-isms, and I'd hate to reintroduce one for this trivial thing. More specifically, here's what's going to happen in Fedora-land, and isn't in RHEL6:

The /etc/sysconfig/network file goes away, and is replaced (for our purposes) with /etc/hostname ,which contains the short name of the hostname. The way I figure it, we can get the hostname one of a few ways here:

Quoted 8 lines

1) Blindly trust that the set hostname is correct (i.e. what the hostname(1) command returns is what we should be using)
2) Read /etc/hostname in a subshell (the HOSTNAME= no longer exists, so it can't be sourced)
3) Fall back on /etc/sysconfig/network if we don't find /etc/hostname if we go with 2.

Thoughts?

Calling ``newname=$(hostname)`` would be better (assuming that the network was setup enough where one could get this information). Thanks!
-Garrett
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 2 lines · Garrett Cooper

Calling ``newname=$(hostname)`` would be better (assuming that the network was setup enough where one could get this information).

Calling hostname is always preferred to mucking about with files in /etc/. hostname never requires the network, hostname -f might sometimes.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20121204181131.GC21196-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#9 lore raw
Quoted 8 lines · Jason Gunthorpe
Quoted 2 lines · Garrett Cooper

Calling ``newname=$(hostname)`` would be better (assuming that the network was setup enough where one could get this information).

Calling hostname is always preferred to mucking about with files in /etc/. hostname never requires the network, hostname -f might sometimes.

Yes, but OSes don't set the hostname until a little later on in the boot process (FreeBSD for instance), depending upon how the system was first booted and the host's network configuration (DHCP*/SLAAC/etc). That's more of what I was driving at when I said "assuming that the network was setup enough where one could get this information".

Thanks,
-Garrett
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAGH67wQrOFpEK4PWK858tuf3yVEzr4D9kWoPuLJCte8wocpAkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw
Quoted 11 lines · On Tue, 4 Dec 2012 11:48:18 -0800 Garrett Cooper…
Quoted 8 lines · Jason Gunthorpe
Quoted 2 lines · Garrett Cooper

Calling ``newname=$(hostname)`` would be better (assuming that the network was setup enough where one could get this information).

Calling hostname is always preferred to mucking about with files in /etc/. hostname never requires the network, hostname -f might sometimes.

Quoted 5 lines

Yes, but OSes don't set the hostname until a little later on in the boot process (FreeBSD for instance), depending upon how the system was first booted and the host's network configuration (DHCP*/SLAAC/etc). That's more of what I was driving at when I said "assuming that the network was setup enough where one could get this information".

set_nodedesc.sh was deprecated and moved to a compat build a while ago.

As such I think the best thing to do is use hostname as Jason says and call it good. I believe that users attempting to set the NodeDescription within boot scripts can do so with the sysfs files.

Jon I would accept a patch if you would like to redo this one but I am going to reject the patch as it stands.

Thanks,
Ira

Quoted 7 lines

Thanks,
-Garrett
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 9 lines
Ira Weiny
Member of Technical Staff
Lawrence Livermore National Lab
925-423-8008
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
In reply to a message not in the archive
Quoted 7 lines · Jason Gunthorpe
Quoted 5 lines · Jon Stanley

Future release of Fedora are going to remove /etc/sysconfig/network which we source to get $HOSTNAME. Bash (and sh) set $HOSTNAME in the shell by default, so we should be safe to use that here. This adds the benefit of working across multiple distributions if that is required in the future.

Quoted 7 lines

This looks like it is a bashism (ie dash does not do this), so you should update the #! to use /bin/bash not /bin/sh...

$ HOSTNAME= /bin/dash
\h{\u}\w#echo $HOSTNAME

\h{\u}\w#

Good catch! I forgot about this important subtlety between bash
and the rest of the bourne shells (I'll need to verify that I didn't leave any "dangling bashisms" in my last patch).
Thanks!
-Garrett

$ set
BASH=/usr/local/bin/bash
BLOCKSIZE=K
EDITOR=vim
ENV=/usr/home/gcooper/.shrc
HOME=/usr/home/gcooper
IFS='
'
LOGNAME=gcooper
MAIL=/var/mail/gcooper
OPTIND=1
P4CLIENT=gcooper-bayonetta
P4PORT=perforce.freebsd.org:1666
P4USER=gcooper
PAGER=more
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/home/gcooper/bin
PPID=9754
PS1='$ '
PS2='> '
PS4='+ '
PWD=/usr/home/gcooper
SHELL=/bin/sh
SHLVL=1
SSH_CLIENT='192.168.20.1 45753 22'
SSH_CONNECTION='192.168.20.1 45753 192.168.20.2 22'
SSH_TTY=/dev/pts/10
TERM=screen
USER=gcooper
_=set
$ bash -c set
BASH=/usr/local/bin/bash
BASHOPTS=cmdhist:colonbreakswords:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="2" [2]="37" [3]="0" [4]="release"
[5]="amd64-portbld-freebsd9.1")
BASH_VERSION='4.2.37(0)-release'
BLOCKSIZE=K
DIRSTACK=()
EDITOR=vim
ENV=/usr/home/gcooper/.shrc
EUID=1000
GROUPS=()
HOME=/usr/home/gcooper
HOSTNAME=bayonetta.local
HOSTTYPE=amd64
IFS=$' \t\n'
LOGNAME=gcooper
MACHTYPE=amd64-portbld-freebsd9.1
MAIL=/var/mail/gcooper
OPTERR=1
OPTIND=1
OSTYPE=freebsd9.1
P4CLIENT=gcooper-bayonetta
P4PORT=perforce.freebsd.org:1666
P4USER=gcooper
PAGER=more
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/home/gcooper/bin
PPID=9758
PS4='+ '
PWD=/usr/home/gcooper
SHELL=/usr/local/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=2
SSH_CLIENT='192.168.20.1 45753 22'
SSH_CONNECTION='192.168.20.1 45753 192.168.20.2 22'
SSH_TTY=/dev/pts/10
TERM=screen
UID=1000
USER=gcooper
_=set
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html