@@ -330,34 +330,37 @@ ssh_settings=$(ssh "${ssh_args[@]}" -G "${ssh_connection}")
330
330
ssh_user=$( echo " $ssh_settings " | awk ' /^user / { print $2 }' )
331
331
ssh_host=$( echo " $ssh_settings " | awk ' /^hostname / { print $2 }' )
332
332
333
- step Uploading install SSH keys
334
- until
335
- if [[ -n ${env_password-} ]]; then
336
- sshpass -e \
333
+ uploadSSHKey () {
334
+ step Uploading install SSH keys
335
+ until
336
+ if [[ -n ${env_password-} ]]; then
337
+ sshpass -e \
338
+ ssh-copy-id \
339
+ -i " $ssh_key_dir " /nixos-anywhere.pub \
340
+ -o ConnectTimeout=10 \
341
+ -o UserKnownHostsFile=/dev/null \
342
+ -o IdentitiesOnly=yes \
343
+ -o StrictHostKeyChecking=no \
344
+ " ${ssh_copy_id_args[@]} " \
345
+ " ${ssh_args[@]} " \
346
+ " $ssh_connection "
347
+ else
337
348
ssh-copy-id \
338
- -i " $ssh_key_dir " /nixos-anywhere.pub \
339
- -o ConnectTimeout=10 \
340
- -o UserKnownHostsFile=/dev/null \
341
- -o IdentitiesOnly=yes \
342
- -o StrictHostKeyChecking=no \
343
- " ${ssh_copy_id_args[@]} " \
344
- " ${ssh_args[@]} " \
345
- " $ssh_connection "
346
- else
347
- ssh-copy-id \
348
- -i " $ssh_key_dir " /nixos-anywhere.pub \
349
- -o ConnectTimeout=10 \
350
- -o UserKnownHostsFile=/dev/null \
351
- -o StrictHostKeyChecking=no \
352
- " ${ssh_copy_id_args[@]} " \
353
- " ${ssh_args[@]} " \
354
- " $ssh_connection "
355
- fi
356
- do
357
- sleep 3
358
- done
349
+ -i " $ssh_key_dir " /nixos-anywhere.pub \
350
+ -o ConnectTimeout=10 \
351
+ -o UserKnownHostsFile=/dev/null \
352
+ -o StrictHostKeyChecking=no \
353
+ " ${ssh_copy_id_args[@]} " \
354
+ " ${ssh_args[@]} " \
355
+ " $ssh_connection "
356
+ fi
357
+ do
358
+ sleep 3
359
+ done
360
+ }
359
361
360
362
importFacts () {
363
+ step Gathering machine facts
361
364
local facts filtered_facts
362
365
if ! facts=$( ssh_ -o ConnectTimeout=10 enable_debug=$enable_debug sh -- < " $here " /get-facts.sh) ; then
363
366
exit 1
@@ -371,28 +374,6 @@ importFacts() {
371
374
export $( echo " $filtered_facts " | xargs)
372
375
}
373
376
374
- step Gathering machine facts
375
- importFacts
376
-
377
- if [[ ${has_tar-n} == " n" ]]; then
378
- abort " no tar command found, but required to unpack kexec tarball"
379
- fi
380
-
381
- if [[ ${has_setsid-n} == " n" ]]; then
382
- abort " no setsid command found, but required to run the kexec script under a new session"
383
- fi
384
-
385
- maybe_sudo=" "
386
- if [[ ${has_sudo-n} == " y" ]]; then
387
- maybe_sudo=" sudo"
388
- elif [[ ${has_doas-n} == " y" ]]; then
389
- maybe_sudo=" doas"
390
- fi
391
-
392
- if [[ ${is_os-n} != " Linux" ]]; then
393
- abort " This script requires Linux as the operating system, but got $is_os "
394
- fi
395
-
396
377
runKexec () {
397
378
if [[ ${is_kexec-n} == " n" ]] && [[ ${is_installer-n} == " n" ]]; then
398
379
if [[ ${is_container-none} != " none" ]]; then
535
516
536
517
}
537
518
519
+ uploadSSHKey
520
+
521
+ importFacts
522
+
523
+ if [[ ${has_tar-n} == " n" ]]; then
524
+ abort " no tar command found, but required to unpack kexec tarball"
525
+ fi
526
+
527
+ if [[ ${has_setsid-n} == " n" ]]; then
528
+ abort " no setsid command found, but required to run the kexec script under a new session"
529
+ fi
530
+
531
+ maybe_sudo=" "
532
+ if [[ ${has_sudo-n} == " y" ]]; then
533
+ maybe_sudo=" sudo"
534
+ elif [[ ${has_doas-n} == " y" ]]; then
535
+ maybe_sudo=" doas"
536
+ fi
537
+
538
+ if [[ ${is_os-n} != " Linux" ]]; then
539
+ abort " This script requires Linux as the operating system, but got $is_os "
540
+ fi
541
+
538
542
if [[ ${phases[kexec]-} == 1 ]]; then
539
543
runKexec
540
544
fi
0 commit comments