Closed renatokrause closed 3 years ago
Closing this issue as bug seems to be fixed already in main branch.
Scenario 1: /etc/hosts file contains only 1 line with "127.0.0.1 localhost"
[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1 localhost
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
PASS Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 1
Scenario 2: /etc/hosts file contains only 2 lines with "127.0.0.1 localhost" and "::1 localhost"
[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
PASS Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 2
Scenario 3: /etc/hosts file contains custom hostname entry
[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.246.18 dummy.meltest.com**
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
WARN Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 3
Although my /etc/hosts file only displayed:
127.0.0.1 localhost
The script continued to display a warning about the presence of a strange entry. In the function "_checknetwork ()", specifically in the line:set -- "$ (echo" $ line "| awk '{print $ 1, $ 2}')"
there should be no quotation marks because it is expected that afterwards there will be two entries: ip, hostname. Therefore, it is necessary to remove the quotation marks, thus:set -- $ (echo "$ line" | awk '{print $ 1, $ 2}')
To facilitate sharing the diff: https://pastebin.com/Q40P6pUJ