Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions turtlebot4_setup/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def __init__(self) -> None:
self.netplan_wifis_file = os.path.join(self.netplan_dir, '50-wifis.yaml')
self.discovery_sh_file = os.path.join(self.setup_dir, 'discovery.sh')
self.hostname_file = '/etc/hostname'
self.fw_user_data_file = '/boot/firmware/user-data'

self.system_conf = copy.deepcopy(self.default_system_conf)
self.wifi_conf = copy.deepcopy(self.default_wifi_conf)
Expand Down Expand Up @@ -230,6 +231,11 @@ def write_system(self):
f.write(self.get(SystemOptions.HOSTNAME))
subprocess.run(shlex.split('sudo mv /tmp' + self.hostname_file + ' ' + self.hostname_file))

# update /boot/firmware/user-data with the new hostname
subprocess.run(shlex.split(f'cp {self.fw_user_data_file} /tmp/user-data'))
subprocess.run(shlex.split(f'sed -i -E "s/^hostname:.+/hostname: {self.get(SystemOptions.HOSTNAME)}/" /tmp/user-data')) # noqa: E501
subprocess.run(shlex.split(f'sudo mv /tmp/user-data {self.fw_user_data_file}'))
Comment thread
hilary-luo marked this conversation as resolved.
Outdated

def read_wifi(self):
try:
# Try to open the existing wifi configuration, but if it doesn't exist we can carry on
Expand Down