dracut-module-setup.sh: improve get_alias()
In /etc/hosts, the alias name can come at the 2nd column, regardless of the recommendation. E.g. the following format is valid although not recommended cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.22.21 fastvm-rhel-7-6-21 fastvm-rhel-7-6-21.localdomain 192.168.22.22 fastvm-rhel-7-6-22 fastvm-rhel-7-6-22.localdomain 192.168.22.21 node1_hb 192.168.22.22 node2_hb So filtering out both 2nd and 3rd column for matching. Signed-off-by: Pingfan Liu <piliu@redhat.com> Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
4b43ba063d
commit
3be5f74df0
@ -683,7 +683,8 @@ get_alias() {
|
||||
ips=$(hostname -I)
|
||||
for ip in $ips
|
||||
do
|
||||
entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0 }')
|
||||
# in /etc/hosts, alias can come at the 2nd column
|
||||
entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }')
|
||||
if [ $? -eq 0 ]; then
|
||||
alias_set="$alias_set $entries"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user