Skip to content

Commit e4f8ad7

Browse files
Mic92mergify[bot]
authored andcommitted
use camel case for all functions
1 parent efe8740 commit e4f8ad7

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/nixos-anywhere.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,20 @@ if [[ ${substitute_on_destination-n} == "y" ]]; then
231231
fi
232232

233233
# ssh wrapper
234-
timeout_ssh_() {
234+
runSSHTimeout() {
235235
timeout 10 ssh -i "$ssh_key_dir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${ssh_args[@]}" "$ssh_connection" "$@"
236236
}
237-
ssh_() {
237+
runSSH() {
238238
ssh "$ssh_tty_param" -i "$ssh_key_dir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${ssh_args[@]}" "$ssh_connection" "$@"
239239
}
240240

241-
nix_copy() {
241+
nixCopy() {
242242
NIX_SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ssh_key_dir/nixos-anywhere ${ssh_args[*]}" nix copy \
243243
"${nix_options[@]}" \
244244
"${nix_copy_options[@]}" \
245245
"$@"
246246
}
247-
nix_build() {
247+
nixBuild() {
248248
NIX_SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ssh_key_dir/nixos-anywhere ${ssh_args[*]}" nix build \
249249
--print-out-paths \
250250
--no-link \
@@ -294,8 +294,8 @@ if [[ -n ${flake-} ]]; then
294294
"${nix_options[@]}" \
295295
"${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.installTest"
296296
fi
297-
disko_script=$(nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript")
298-
nixos_system=$(nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel")
297+
disko_script=$(nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript")
298+
nixos_system=$(nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel")
299299
fi
300300
elif [[ -n ${disko_script-} ]] && [[ -n ${nixos_system-} ]]; then
301301
if [[ -n ${vm_test-} ]]; then
@@ -362,7 +362,7 @@ uploadSSHKey() {
362362
importFacts() {
363363
step Gathering machine facts
364364
local facts filtered_facts
365-
if ! facts=$(ssh_ -o ConnectTimeout=10 enable_debug=$enable_debug sh -- <"$here"/get-facts.sh); then
365+
if ! facts=$(runSSH -o ConnectTimeout=10 enable_debug=$enable_debug sh -- <"$here"/get-facts.sh); then
366366
exit 1
367367
fi
368368
filtered_facts=$(echo "$facts" | grep -E '^(has|is)_[a-z0-9_]+=\S+')
@@ -392,7 +392,7 @@ runKexec() {
392392
fi
393393

394394
step Switching system into kexec
395-
ssh_ sh <<SSH
395+
runSSH sh <<SSH
396396
set -efu ${enable_debug}
397397
$maybe_sudo rm -rf /root/kexec
398398
$maybe_sudo mkdir -p /root/kexec
@@ -404,16 +404,16 @@ SSH
404404
fi
405405

406406
if [[ -f $kexec_url ]]; then
407-
ssh_ "${maybe_sudo} tar -C /root/kexec -xvzf-" <"$kexec_url"
407+
runSSH "${maybe_sudo} tar -C /root/kexec -xvzf-" <"$kexec_url"
408408
elif [[ ${has_curl-n} == "y" ]]; then
409-
ssh_ "curl --fail -Ss -L '${kexec_url}' | ${maybe_sudo} tar -C /root/kexec -xvzf-"
409+
runSSH "curl --fail -Ss -L '${kexec_url}' | ${maybe_sudo} tar -C /root/kexec -xvzf-"
410410
elif [[ ${has_wget-n} == "y" ]]; then
411-
ssh_ "wget '${kexec_url}' -O- | ${maybe_sudo} tar -C /root/kexec -xvzf-"
411+
runSSH "wget '${kexec_url}' -O- | ${maybe_sudo} tar -C /root/kexec -xvzf-"
412412
else
413-
curl --fail -Ss -L "${kexec_url}" | ssh_ "${maybe_sudo} tar -C /root/kexec -xvzf-"
413+
curl --fail -Ss -L "${kexec_url}" | runSSH "${maybe_sudo} tar -C /root/kexec -xvzf-"
414414
fi
415415

416-
ssh_ <<SSH
416+
runSSH <<SSH
417417
TMPDIR=/root/kexec setsid ${maybe_sudo} /root/kexec/kexec/run --kexec-extra-flags "${kexec_extra_flags}"
418418
SSH
419419

@@ -426,66 +426,66 @@ SSH
426426
done
427427

428428
# wait for machine to become unreachable.
429-
while timeout_ssh_ -- exit 0; do sleep 1; done
429+
while runSshTimeout -- exit 0; do sleep 1; done
430430

431431
# After kexec we explicitly set the user to root@
432432
ssh_connection="root@${ssh_host}"
433433

434434
# waiting for machine to become available again
435-
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
435+
until runSSH -o ConnectTimeout=10 -- exit 0; do sleep 5; done
436436
fi
437437
}
438438

439439
runDisko() {
440440
local disko_script=$1
441441
for path in "${!disk_encryption_keys[@]}"; do
442442
step "Uploading ${disk_encryption_keys[$path]} to $path"
443-
ssh_ "umask 077; cat > $path" <"${disk_encryption_keys[$path]}"
443+
runSSH "umask 077; cat > $path" <"${disk_encryption_keys[$path]}"
444444
done
445445
if [[ -n ${disko_script-} ]]; then
446-
nix_copy --to "ssh://$ssh_connection" "$disko_script"
446+
nixCopy --to "ssh://$ssh_connection" "$disko_script"
447447
elif [[ ${build_on_remote-n} == "y" ]]; then
448448
step Building disko script
449449
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
450-
nix_copy --to "ssh-ng://$ssh_connection" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
450+
nixCopy --to "ssh-ng://$ssh_connection" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
451451
--derivation --no-check-sigs
452452
disko_script=$(
453-
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
453+
nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
454454
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir/nixos-anywhere"
455455
)
456456
fi
457457

458458
step Formatting hard drive with disko
459-
ssh_ "$disko_script"
459+
runSSH "$disko_script"
460460
}
461461

462462
nixosInstall() {
463463
if [[ -n ${nixos_system-} ]]; then
464464
step Uploading the system closure
465-
nix_copy --to "ssh://$ssh_connection?remote-store=local?root=/mnt" "$nixos_system"
465+
nixCopy --to "ssh://$ssh_connection?remote-store=local?root=/mnt" "$nixos_system"
466466
elif [[ ${build_on_remote-n} == "y" ]]; then
467467
step Building the system closure
468468
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
469-
nix_copy --to "ssh-ng://$ssh_connection?remote-store=local?root=/mnt" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
469+
nixCopy --to "ssh-ng://$ssh_connection?remote-store=local?root=/mnt" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
470470
--derivation --no-check-sigs
471471
nixos_system=$(
472-
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
472+
nixBuild "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
473473
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir/nixos-anywhere&remote-store=local?root=/mnt"
474474
)
475475
fi
476476

477477
if [[ -n ${extra_files-} ]]; then
478478
step Copying extra files
479-
tar -C "$extra_files" -cpf- . | ssh_ "${maybe_sudo} tar -C /mnt -xf- --no-same-owner"
480-
ssh_ "chmod 755 /mnt" # tar also changes permissions of /mnt
479+
tar -C "$extra_files" -cpf- . | runSSH "${maybe_sudo} tar -C /mnt -xf- --no-same-owner"
480+
runSSH "chmod 755 /mnt" # tar also changes permissions of /mnt
481481
fi
482482

483483
step Installing NixOS
484484
maybeReboot=""
485485
if [[ ${phases[reboot]-} == 1 ]]; then
486486
maybeReboot="nohup sh -c 'sleep 6 && reboot' >/dev/null &"
487487
fi
488-
ssh_ sh <<SSH
488+
runSSH sh <<SSH
489489
set -eu ${enable_debug}
490490
# when running not in nixos we might miss this directory, but it's needed in the nixos chroot during installation
491491
export PATH="\$PATH:/run/current-system/sw/bin"
@@ -547,7 +547,7 @@ fi
547547
# Switch to root user by copying authorized_keys.
548548
if [[ ${is_installer-n} == "y" ]] && [[ ${ssh_user} != "root" ]]; then
549549
# Allow copy to fail if authorized_keys does not exist, like if using /etc/ssh/authorized_keys.d/
550-
ssh_ "${maybe_sudo} mkdir -p /root/.ssh; ${maybe_sudo} cp ~/.ssh/authorized_keys /root/.ssh || true"
550+
runSSH "${maybe_sudo} mkdir -p /root/.ssh; ${maybe_sudo} cp ~/.ssh/authorized_keys /root/.ssh || true"
551551
ssh_connection="root@${ssh_host}"
552552
fi
553553

@@ -561,7 +561,7 @@ fi
561561

562562
if [[ ${phases[reboot]-} == 1 ]]; then
563563
step Waiting for the machine to become unreachable due to reboot
564-
while timeout_ssh_ -- exit 0; do sleep 1; done
564+
while runSshTimeout -- exit 0; do sleep 1; done
565565
fi
566566

567567
step "Done!"

0 commit comments

Comments
 (0)