File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ def __init__(self) -> None:
130130 self .netplan_wifis_file = os .path .join (self .netplan_dir , '50-wifis.yaml' )
131131 self .discovery_sh_file = os .path .join (self .setup_dir , 'discovery.sh' )
132132 self .hostname_file = '/etc/hostname'
133+ self .fw_user_data_file = '/boot/firmware/user-data'
133134
134135 self .system_conf = copy .deepcopy (self .default_system_conf )
135136 self .wifi_conf = copy .deepcopy (self .default_wifi_conf )
@@ -230,6 +231,11 @@ def write_system(self):
230231 f .write (self .get (SystemOptions .HOSTNAME ))
231232 subprocess .run (shlex .split ('sudo mv /tmp' + self .hostname_file + ' ' + self .hostname_file ))
232233
234+ # update /boot/firmware/user-data with the new hostname
235+ subprocess .run (shlex .split (f'cp { self .fw_user_data_file } /tmp/user-data' ))
236+ subprocess .run (shlex .split (f'sed -i -E "s/^hostname:.+/hostname: { self .get (SystemOptions .HOSTNAME )} /" /tmp/user-data' ))
237+ subprocess .run (shlex .split (f'sudo mv /tmp/user-data { self .fw_user_data_file } ' ))
238+
233239 def read_wifi (self ):
234240 try :
235241 # Try to open the existing wifi configuration, but if it doesn't exist we can carry on
You can’t perform that action at this time.
0 commit comments