File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -408,6 +408,7 @@ def post_install(self):
408408 def generate_install (self ):
409409 with open ('/etc/turtlebot4/discovery.conf' ) as f :
410410 discovery_conf_contents = f .read ()
411+ discovery_conf_contents = self .fix_conf_username (discovery_conf_contents )
411412 with open ('/etc/turtlebot4/discovery.sh' ) as f :
412413 discovery_sh_contents = f .read ()
413414 return {
@@ -434,3 +435,15 @@ def generate_uninstall(self):
434435 '/etc/systemd/system/multi-user.target.wants/discovery.service' : {
435436 'remove' : True
436437 }}
438+
439+ def fix_conf_username (self , discovery_conf_contents ):
440+ """
441+ Replace the `User=ubuntu` text in the configuration with the current username
442+
443+ @return The modified config file contents
444+ """
445+ if os .getlogin () == 'ubuntu' :
446+ # no changes needed!
447+ return discovery_conf_contents
448+
449+ return discovery_conf_contents .replace ('User=ubuntu' , f'User={ os .getlogin ()} ' )
You can’t perform that action at this time.
0 commit comments