aboutsummaryrefslogtreecommitdiff
path: root/local.sh
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-08-09 09:20:02 +0200
committerKarel Kočí <cynerd@email.cz>2022-08-09 09:20:02 +0200
commit33356ec9bc1a1571491894c6edef73df181f9ac9 (patch)
tree567833c1243b403538b460c63a660a851e6eec5b /local.sh
parent3649c233b73d03370779a8f58c6613a412979e8b (diff)
downloadnixos-personal-33356ec9bc1a1571491894c6edef73df181f9ac9.tar.gz
nixos-personal-33356ec9bc1a1571491894c6edef73df181f9ac9.tar.bz2
nixos-personal-33356ec9bc1a1571491894c6edef73df181f9ac9.zip
Add local.sh script to update local machine
Yes there is nixos-rebuild but this turns out to be for me much more handy when updating and testing system.
Diffstat (limited to 'local.sh')
-rwxr-xr-xlocal.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/local.sh b/local.sh
new file mode 100755
index 0000000..37985c3
--- /dev/null
+++ b/local.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+source "${0%/*}/common.sh"
+
+operations() {
+ for op in "$@"; do
+ if ! "$op" "$(hostname)"; then
+ error "Operation '$op' failed" >&2
+ break
+ fi
+ done
+}
+
+################################################################################
+operation="${1:-}"
+if [ $# -gt 1 ]; then
+ echo "Invalid argument: $2" >&2
+ exit 2
+fi
+
+case "$operation" in
+ help|h)
+ cat <<-EOF
+ Usage $0 operation [device]...
+ Local system builder and updater for remote devices.
+
+ Operations:
+ build: build device system
+ boot: set built system to be boot default on the device
+ switch: switch to the built system on the target device
+ test: test the built system on the target device
+ EOF
+ ;;
+ build|b)
+ operations build
+ ;;
+ boot)
+ operations boot
+ ;;
+ switch|s)
+ operations switch
+ ;;
+ test|t)
+ operations switch_test
+ ;;
+ build-switch|bs|"")
+ operations build switch
+ ;;
+ build-test|bt)
+ operations build switch_test
+ ;;
+ build-boot|bb)
+ operations build boot
+ ;;
+ default)
+ echo "Unknown operation: $operation" >&2
+ exit 2
+ ;;
+esac