fix: escaping in deploy/build

This commit is contained in:
Patrick 2024-11-14 21:47:14 +01:00
parent 2d330b3f4a
commit 592cb0753b
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
2 changed files with 13 additions and 13 deletions

View file

@ -37,19 +37,19 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
[[ ! ''${#POSITIONAL_ARGS[@]} -lt 1 ]] || [[ ! ${#POSITIONAL_ARGS[@]} -lt 1 ]] ||
die "Missing argument: <hosts,...>" die "Missing argument: <hosts,...>"
[[ ! ''${#POSITIONAL_ARGS[@]} -gt 1 ]] || [[ ! ${#POSITIONAL_ARGS[@]} -gt 1 ]] ||
die "Too many arguments" die "Too many arguments"
shopt -s lastpipe shopt -s lastpipe
tr , '\n' <<<"''${POSITIONAL_ARGS[0]}" | sort -u | readarray -t HOSTS tr , '\n' <<<"${POSITIONAL_ARGS[0]}" | sort -u | readarray -t HOSTS
NIXOS_CONFIGS=() NIXOS_CONFIGS=()
for host in "''${HOSTS[@]}"; do for host in "${HOSTS[@]}"; do
NIXOS_CONFIGS+=(".#nixosConfigurations.$host.config.system.build.toplevel") NIXOS_CONFIGS+=(".#nixosConfigurations.$host.config.system.build.toplevel")
done done
echo -e "Building toplevels for \033[0;32m''${#HOSTS[*]} hosts\033[0m" echo -e "Building toplevels for \033[0;32m${#HOSTS[*]} hosts\033[0m"
nom build --print-out-paths --no-link "${OPTIONS[@]}" "${NIXOS_CONFIGS[@]}" || nom build --print-out-paths --no-link "${OPTIONS[@]}" "${NIXOS_CONFIGS[@]}" ||
die "Failed building derivations" die "Failed building derivations"

View file

@ -47,15 +47,15 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
[[ ! ''${#POSITIONAL_ARGS[@]} -lt 1 ]] || [[ ! ${#POSITIONAL_ARGS[@]} -lt 1 ]] ||
die "Missing argument: <hosts,...>" die "Missing argument: <hosts,...>"
[[ ! ''${#POSITIONAL_ARGS[@]} -gt 2 ]] || [[ ! ${#POSITIONAL_ARGS[@]} -gt 2 ]] ||
die "Too many arguments" die "Too many arguments"
shopt -s lastpipe shopt -s lastpipe
tr , '\n' <<<"''${POSITIONAL_ARGS[0]}" | sort -u | readarray -t HOSTS tr , '\n' <<<"${POSITIONAL_ARGS[0]}" | sort -u | readarray -t HOSTS
ACTION="''${POSITIONAL_ARGS[1]-switch}" ACTION="${POSITIONAL_ARGS[1]-switch}"
function main() { function main() {
local system local system
@ -63,8 +63,8 @@ function main() {
if [[ $1 == *"@"* ]]; then if [[ $1 == *"@"* ]]; then
arr=() arr=()
echo -n "$1" | readarray -d "@" -t arr echo -n "$1" | readarray -d "@" -t arr
system="''${arr[0]}" system="${arr[0]}"
host="root@''${arr[1]}" host="root@${arr[1]}"
else else
system=$1 system=$1
host=$system host=$system
@ -99,9 +99,9 @@ function main() {
) )
} }
echo -e "Building toplevels for \033[0;32m''${#HOSTS[*]} hosts\033[0m" echo -e "Building toplevels for \033[0;32m${#HOSTS[*]} hosts\033[0m"
for host in "''${HOSTS[@]}"; do for host in "${HOSTS[@]}"; do
main "$host" & main "$host" &
done done
wait wait