Skip to content

Commit

Permalink
fixing dns issues
Browse files Browse the repository at this point in the history
fixing hostname
  • Loading branch information
jackyalbo authored and nimrod-becker committed Oct 23, 2017
1 parent 023ab88 commit 2aab724
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/deploy/NVA_build/first_install_diaglog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ function configure_dns_dialog {
dns1=$(head -1 answer_dns)
dns2=$(tail -1 answer_dns)
done

sudo sed -i "s/.*NooBaa Configured Primary DNS Server//" /etc/resolv.conf
sudo sed -i "s/.*NooBaa Configured Secondary DNS Server//" /etc/resolv.conf

sudo bash -c "echo 'search localhost.localdomain' > /etc/resolv.conf"
sudo bash -c "echo 'nameserver ${dns1} #NooBaa Configured Primary DNS Server' >> /etc/resolv.conf"
if [ "${dns2}" != "" ]; then
sudo bash -c "echo 'nameserver ${dns2} #NooBaa Configured Secondary DNS Server' >> /etc/resolv.conf"
else
sudo bash -c "echo '#NooBaa Configured Secondary DNS Server' >> /etc/resolv.conf"
fi
sudo bash -c "echo '#NooBaa Configured Search' >> /etc/resolv.conf"
sudo supervisorctl restart all > /dev/null 2>&1
}

Expand Down
6 changes: 3 additions & 3 deletions src/server/bg_services/server_monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ function _verify_dns_cluster_config() {
dns_servers: _.compact(server_conf.dns_servers),
search_domains: _.compact(server_conf.search_domains)
};
return os_utils.get_dns_servers()
.then(platform_dns_config => {
return P.all([os_utils.get_dns_servers(), fs_utils.find_line_in_file('/etc/sysconfig/network-scripts/ifcfg-eth0', 'BOOTPROTO="dhcp"')])
.spread((platform_dns_config, dhcp) => {
if (!_are_platform_and_cluster_conf_equal(platform_dns_config, cluster_conf)) {
dbg.warn(`platform dns settings not synced to cluster. Platform conf: `, platform_dns_config, 'cluster_conf:', cluster_conf);
return os_utils.set_dns_server(cluster_conf)
.then(() => os_utils.restart_services());
.then(() => dhcp && os_utils.restart_services());
}
})
.catch(err => dbg.error('failed to reconfigure dns cluster config on the server. reason:', err));
Expand Down
15 changes: 8 additions & 7 deletions src/util/os_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,11 @@ function get_dns_servers() {
})
.filter(regex_group => !_.isEmpty(regex_group));

dns_config.search_domains = conf_lines.map(line => {
let regex_res = (/search (.*) #NooBaa/).exec(line);
return regex_res && regex_res[1];
})
.filter(regex_group => !_.isEmpty(regex_group));
conf_lines.forEach(line => {
let regex_res = (/search (.*) #NooBaa/).exec(line);
let splitted_result = regex_res && regex_res[1].split(' ');
if (splitted_result) dns_config.search_domains.push(...splitted_result);
});
return dns_config;
});
} else if (os.type() === 'Darwin') { //Bypass for dev environment
Expand Down Expand Up @@ -554,7 +554,7 @@ function set_dns_server(servers, search_domains) {

if (search_domains && search_domains.length) {
commands_to_exec.push("sed -i 's/.*NooBaa Configured Search.*/search " +
search_domains + " #NooBaa Configured Search/' /etc/resolv.conf");
search_domains.toString().replace(/,/g, ' ') + " #NooBaa Configured Search/' /etc/resolv.conf");
} else {
commands_to_exec.push("sed -i 's/.*NooBaa Configured Search.*/#NooBaa Configured Search/' /etc/resolv.conf");
}
Expand Down Expand Up @@ -795,7 +795,8 @@ function set_hostname(hostname) {
return P.resolve();
}

return promise_utils.exec(`hostname ${hostname}`);
return promise_utils.exec(`hostname ${hostname}`)
.then(() => promise_utils.exec(`sed -i "s/^HOSTNAME=.*/HOSTNAME=${hostname}/g" /etc/sysconfig/network`)); // keep it permanent
}

function is_valid_hostname(hostname_string) {
Expand Down

0 comments on commit 2aab724

Please sign in to comment.