@@ -34,6 +34,20 @@ postKexecSshPort=22
34
34
buildOnRemote=n
35
35
envPassword=n
36
36
37
+ # Facts set by get-facts.sh
38
+ isOs=
39
+ isArch=
40
+ isKexec=
41
+ isInstaller=
42
+ isContainer=
43
+ hasIpv6Only=
44
+ hasTar=
45
+ hasSudo=
46
+ hasDoas=
47
+ hasWget=
48
+ hasCurl=
49
+ hasSetsid=
50
+
37
51
sshKeyDir=$( mktemp -d)
38
52
trap ' rm -rf "$sshKeyDir"' EXIT
39
53
mkdir -p " $sshKeyDir "
@@ -359,19 +373,25 @@ importFacts() {
359
373
# make facts available in script
360
374
# shellcheck disable=SC2046
361
375
export $( echo " $filteredFacts " | xargs)
376
+
377
+ for var in isOs isArch isKexec isInstaller isContainer hasIpv6Only hasTar hasSudo hasDoas hasWget hasCurl hasSetsid; do
378
+ if [[ -z ${! var} ]]; then
379
+ abort " Failed to retrieve fact $var from host"
380
+ fi
381
+ done
362
382
}
363
383
364
384
runKexec () {
365
- if [[ ${isKexec-n } == " y" ]] || [[ ${isInstaller-n } == " y" ]]; then
385
+ if [[ ${isKexec} == " y" ]] || [[ ${isInstaller} == " y" ]]; then
366
386
return
367
387
fi
368
388
369
- if [[ ${isContainer-none } != " none" ]]; then
389
+ if [[ ${isContainer} != " none" ]]; then
370
390
echo " WARNING: This script does not support running from a '${isContainer} ' container. kexec will likely not work" >&2
371
391
fi
372
392
373
393
if [[ $kexecUrl == " " ]]; then
374
- case " ${isArch-unknown } " in
394
+ case " ${isArch} " in
375
395
x86_64 | aarch64)
376
396
kexecUrl=" https://github.com/nix-community/nixos-images/releases/download/nixos-24.05/nixos-kexec-installer-noninteractive-${isArch} -linux.tar.gz"
377
397
;;
@@ -389,15 +409,15 @@ $maybeSudo mkdir -p /root/kexec
389
409
SSH
390
410
391
411
# no way to reach global ipv4 destinations, use gh-v6.com automatically if github url
392
- if [[ ${hasIpv6Only-n } == " y" ]] && [[ $kexecUrl == " https://github.com/" * ]]; then
412
+ if [[ ${hasIpv6Only} == " y" ]] && [[ $kexecUrl == " https://github.com/" * ]]; then
393
413
kexecUrl=${kexecUrl/ " github.com" / " gh-v6.com" }
394
414
fi
395
415
396
416
if [[ -f $kexecUrl ]]; then
397
417
runSsh " ${maybeSudo} tar -C /root/kexec -xvzf-" < " $kexecUrl "
398
- elif [[ ${hasCurl-n } == " y" ]]; then
418
+ elif [[ ${hasCurl} == " y" ]]; then
399
419
runSsh " curl --fail -Ss -L '${kexecUrl} ' | ${maybeSudo} tar -C /root/kexec -xvzf-"
400
- elif [[ ${hasWget-n } == " y" ]]; then
420
+ elif [[ ${hasWget} == " y" ]]; then
401
421
runSsh " wget '${kexecUrl} ' -O- | ${maybeSudo} tar -C /root/kexec -xvzf-"
402
422
else
403
423
curl --fail -Ss -L " ${kexecUrl} " | runSsh " ${maybeSudo} tar -C /root/kexec -xvzf-"
@@ -560,7 +580,7 @@ main() {
560
580
maybeSudo=" doas"
561
581
fi
562
582
563
- if [[ ${isOs-n } != " Linux" ]]; then
583
+ if [[ ${isOs} != " Linux" ]]; then
564
584
abort " This script requires Linux as the operating system, but got $isOs "
565
585
fi
566
586
0 commit comments