@@ -221,6 +221,7 @@ class Options:
221
221
dhcp_subnet : int
222
222
dhcp_range : Tuple [IPAddress , IPAddress ]
223
223
pixiecore_http_port : int
224
+ pause_after_completion : bool
224
225
nixos_anywhere_args : List [str ]
225
226
226
227
@@ -259,6 +260,11 @@ def parse_args(args: list[str]) -> Options:
259
260
default = 64172 ,
260
261
type = int ,
261
262
)
263
+ parser .add_argument (
264
+ "--pause-after-completion" ,
265
+ help = "Whether to wait for user confimation before tearing down the network setup once the installation completed" ,
266
+ action = "store_true"
267
+ )
262
268
263
269
parsed , unknown_args = parser .parse_known_args (args )
264
270
try :
@@ -296,6 +302,7 @@ def parse_args(args: list[str]) -> Options:
296
302
dhcp_range = (start_ip , stop_ip ),
297
303
dhcp_interface = parsed .dhcp_interface ,
298
304
pixiecore_http_port = parsed .pixiecore_http_port ,
305
+ pause_after_completion = parsed .pause_after_completion ,
299
306
nixos_anywhere_args = unknown_args ,
300
307
)
301
308
@@ -366,6 +373,9 @@ def build_pxe_image(netboot_image_flake: str) -> Path:
366
373
)
367
374
return Path (res .stdout .strip ())
368
375
376
+ def pause ():
377
+ print ("" )
378
+ input ("Press [enter] to terminate this script and tear down the network to the server." )
369
379
370
380
def run_nixos_remote (options : Options ):
371
381
pxe_image_store_path = build_pxe_image (options .netboot_image_flake )
@@ -402,8 +412,13 @@ def run_nixos_remote(options: Options):
402
412
)
403
413
print (f" ssh -i { ssh_key .private_key } root@{ event .ip_addr } " )
404
414
nixos_remote (event .ip_addr , options .flake , ssh_key .private_key , options .nixos_anywhere_args )
415
+ # to avoid having to reboot physical machines all the time because networking disappears:
416
+ if (options .pause_after_completion ):
417
+ print ("You can connect to the machine by doing:" )
418
+ print (f" ssh -i { ssh_key .private_key } root@{ event .ip_addr } " )
419
+ pause ()
405
420
return
406
- print ("after" )
421
+ print ("after" ) # i dont think this is ever printed, because the loop only exits by returning the entire function
407
422
except Exception as e :
408
423
print (e )
409
424
except KeyboardInterrupt :
0 commit comments