Skip to content
Merged
Changes from all 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
13 changes: 13 additions & 0 deletions turtlebot4_setup/ros_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def post_install(self):
def generate_install(self):
with open('/etc/turtlebot4/discovery.conf') as f:
discovery_conf_contents = f.read()
discovery_conf_contents = self.fix_conf_username(discovery_conf_contents)
with open('/etc/turtlebot4/discovery.sh') as f:
discovery_sh_contents = f.read()
return {
Expand All @@ -434,3 +435,15 @@ def generate_uninstall(self):
'/etc/systemd/system/multi-user.target.wants/discovery.service': {
'remove': True
}}

def fix_conf_username(self, discovery_conf_contents):
"""
Replace the `User=ubuntu` text in the configuration with the current username

@return The modified config file contents
"""
if os.getlogin() == 'ubuntu':
# no changes needed!
return discovery_conf_contents

return discovery_conf_contents.replace('User=ubuntu', f'User={os.getlogin()}')
Loading