Client: Fix /etc/hosts file with hostname.local, this is needed for ROS

This commit is contained in:
Arthur Golubtsov
2019-11-15 06:49:20 +00:00
parent 466954c225
commit fcba38fdfa
2 changed files with 2 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ systemctl restart dhcpcd
cat << EOF | tee /etc/hostname
$3
EOF
sed -i "/127.0.1.1/c 127.0.1.1 $3" /etc/hosts
sed -i "/127.0.1.1/c 127.0.1.1 $3 $3.local" /etc/hosts
# set hostname for ROS
sed -i "/ROS_HOSTNAME/c ROS_HOSTNAME=\'$3\'" /home/pi/.bashrc

View File

@@ -217,7 +217,7 @@ def configure_hosts(hostname):
_ip, current_hostname = raw_content[index_start:index_stop].split()
if current_hostname != hostname:
content = raw_content[:index_start] + "{} {}".format(_ip, hostname) + raw_content[index_stop:]
content = raw_content[:index_start] + "{} {} {}".format(_ip, hostname, hostname+'.local') + raw_content[index_stop:]
try:
with open(path, 'w') as f:
f.write(content)