mirror of
https://github.com/nix-community/nixos-anywhere.git
synced 2024-09-11 16:45:28 +03:00
remove POSIX sh
Use [[ ]] everywhere, use :- instead of +x
This commit is contained in:
parent
8db4c0a233
commit
170ef13bfb
14
nixos-remote
14
nixos-remote
@ -57,7 +57,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
set -x
|
set -x
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ -z ${ssh_connection+x} ]; then
|
if [[ -z ${ssh_connection:-} ]]; then
|
||||||
if [[ "$1" =~ ^ssh:// ]]; then
|
if [[ "$1" =~ ^ssh:// ]]; then
|
||||||
ssh_connection=$1
|
ssh_connection=$1
|
||||||
else
|
else
|
||||||
@ -92,24 +92,24 @@ nix_build() {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z ${ssh_connection+x} ]; then
|
if [[ -z ${ssh_connection:-} ]]; then
|
||||||
abort "ssh-host must be set"
|
abort "ssh-host must be set"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# parse flake nixos-install style syntax, get the system attr
|
# parse flake nixos-install style syntax, get the system attr
|
||||||
if [[ -n "${flake+x}" ]]; then
|
if [[ -n "${flake:-}" ]]; then
|
||||||
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
|
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
|
||||||
flake="${BASH_REMATCH[1]}"
|
flake="${BASH_REMATCH[1]}"
|
||||||
flakeAttr="${BASH_REMATCH[2]}"
|
flakeAttr="${BASH_REMATCH[2]}"
|
||||||
fi
|
fi
|
||||||
if [[ -z "${flakeAttr+x}" ]]; then
|
if [[ -z "${flakeAttr:-}" ]]; then
|
||||||
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri."
|
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri."
|
||||||
echo "For example, to use the output nixosConfigurations.foo from the flake.nix, append \"#foo\" to the flake-uri."
|
echo "For example, to use the output nixosConfigurations.foo from the flake.nix, append \"#foo\" to the flake-uri."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
disko_script=$(nix_build "${flake}#nixosConfigurations.${flakeAttr}.config.system.build.disko")
|
disko_script=$(nix_build "${flake}#nixosConfigurations.${flakeAttr}.config.system.build.disko")
|
||||||
nixos_system=$(nix_build "${flake}#nixosConfigurations.${flakeAttr}.config.system.build.toplevel")
|
nixos_system=$(nix_build "${flake}#nixosConfigurations.${flakeAttr}.config.system.build.toplevel")
|
||||||
elif [[ -n "${disko_script+x}" ]] && [[ -n "${nixos_system+x}" ]]; then
|
elif [[ -n "${disko_script:-}" ]] && [[ -n "${nixos_system:-}" ]]; then
|
||||||
if [[ ! -e "${disko_script}" ]] || [[ ! -e "${nixos_system}" ]]; then
|
if [[ ! -e "${disko_script}" ]] || [[ ! -e "${nixos_system}" ]]; then
|
||||||
echo "${disko_script} and ${nixos_system} must be existing store-paths"
|
echo "${disko_script} and ${nixos_system} must be existing store-paths"
|
||||||
exit 1
|
exit 1
|
||||||
@ -121,7 +121,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# wait for machine to become reachable (possibly forever)
|
# wait for machine to become reachable (possibly forever)
|
||||||
if [ ${no_ssh_copy-n} != "y" ]; then
|
if [[ ${no_ssh_copy-n} != "y" ]]; then
|
||||||
until ssh-copy-id -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection"; do sleep 5; done
|
until ssh-copy-id -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$ssh_connection"; do sleep 5; done
|
||||||
else
|
else
|
||||||
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
|
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
|
||||||
@ -132,7 +132,7 @@ if ssh_ -- test -e /etc/is_kexec; then
|
|||||||
is_kexec=y
|
is_kexec=y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${is_kexec-n} != "y" ]; then
|
if [[ ${is_kexec-n} != "y" ]]; then
|
||||||
# TODO we probably need an architecture detection here
|
# TODO we probably need an architecture detection here
|
||||||
ssh_ << SSH
|
ssh_ << SSH
|
||||||
set -efu
|
set -efu
|
||||||
|
Loading…
Reference in New Issue
Block a user