aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-08-22 10:43:42 +0200
committerKarel Kočí <cynerd@email.cz>2022-08-22 10:44:11 +0200
commit0068b7a9cc019e2a8c2c4d92b0a31e8823df2787 (patch)
tree4153638110cca6c66bb15510e3cc8c3c6f5e392a
parent31105755a9b8a1861836ee9f48ce4a9178f95c1a (diff)
downloadnixos-personal-0068b7a9cc019e2a8c2c4d92b0a31e8823df2787.tar.gz
nixos-personal-0068b7a9cc019e2a8c2c4d92b0a31e8823df2787.tar.bz2
nixos-personal-0068b7a9cc019e2a8c2c4d92b0a31e8823df2787.zip
devices.sh: allow using ssh host name instead of network host name
-rw-r--r--common.sh8
-rwxr-xr-xdevices.sh14
2 files changed, 18 insertions, 4 deletions
diff --git a/common.sh b/common.sh
index 4f005de..1af840d 100644
--- a/common.sh
+++ b/common.sh
@@ -35,6 +35,11 @@ sshdest() {
awk -F- 'NF > 1 { print $2"."$1; exit } { print $1 }' <<<"$1"
}
+# Reverse opeartion for sshdest
+sshhost() {
+ awk -F. 'NF > 1 { print $2"-"$1; exit } { print $1 }' <<<"$1"
+}
+
_sh() {
if [ $# -gt 1 ]; then
"$@"
@@ -92,6 +97,9 @@ build() {
if [ "$(device_system "$device")" = "armv7l-linux" ]; then
toplevel=".config.system.build.cross.x86_64-linux${toplevel}"
fi
+ if [ "$(device_system "$device")" = "aarch64-linux" ]; then
+ toplevel=".config.system.build.cross.x86_64-linux${toplevel}"
+ fi
stage "Building system for device: $device"
nix build \
diff --git a/devices.sh b/devices.sh
index 3a2dce5..6c1f30b 100755
--- a/devices.sh
+++ b/devices.sh
@@ -42,11 +42,17 @@ operation="${1:-}"
declare -a selected_devices
if [ $# -gt 0 ]; then
for device in "$@"; do
- if ! valid_device "$device"; then
- error "No such device: $device" >&2
- exit 2
+ if valid_device "$device"; then
+ selected_devices+=("$device")
+ else
+ asdev="$(sshhost "$device")"
+ if valid_device "$asdev"; then
+ selected_devices+=("$asdev")
+ else
+ error "No such device: $device" >&2
+ exit 2
+ fi
fi
- selected_devices+=("$device")
done
else
selected_devices=("${devices[@]}")