2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 11:42:05 +00:00

Merge pull request #4551 from stanford-rc/mkresolvconf_ns

Use all name servers from site.nameservers in mkresolvconf
This commit is contained in:
Yuan Bai 2018-03-06 14:38:48 +08:00 committed by GitHub
commit fec0b8a75d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ conf_file_bak="/etc/resolv.conf.bak"
# get values set when the myxcatpost_<node> script was run
master=$MASTER_IP # this is the ip for the nodes xcatmaster attribute
domain=$DOMAIN # this is the domain name used in this cluster
nameservers=$NAMESERVERS # nameservers defined in the site table
node=$NODE
if [ -n "$master" ] && [ -n "$domain" ]; then
@ -24,7 +25,15 @@ if [ -n "$master" ] && [ -n "$domain" ]; then
#logger -t xcat "Created /etc/resolv.conf file on $node."
cp $conf_file $conf_file_bak > /dev/null 2>&1
echo "search $domain" >$conf_file
echo "nameserver $master" >>$conf_file
if [[ "$nameservers" != "" ]]; then
for ns in ${nameservers//,/ }; do
grep -q $ns $conf_file || \
echo "nameserver ${ns/<xcatmaster>/$master}" >>$conf_file
done
else
echo "nameserver $master" >>$conf_file
fi
else
logger -t xcat -p local4.err "Could not create resolv.conf on $node."
exit 1