New option --and-reboot to immediately reboot host after applying config
This commit is contained in:
12
README.md
12
README.md
@@ -35,6 +35,18 @@ Apply change during next boot:
|
|||||||
bij apply astatine --on-next-boot
|
bij apply astatine --on-next-boot
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reboot host after applying config:
|
||||||
|
|
||||||
|
```
|
||||||
|
bij apply astatine --and-reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
Combine activation and reboot:
|
||||||
|
|
||||||
|
```
|
||||||
|
bij apply astatine --on-next-boot --and-reboot
|
||||||
|
```
|
||||||
|
|
||||||
Sometimes it is required to execute some commands on a host directly.
|
Sometimes it is required to execute some commands on a host directly.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
16
bij.sh
16
bij.sh
@@ -7,6 +7,7 @@ TARGET=
|
|||||||
ON_NEXT_BOOT=
|
ON_NEXT_BOOT=
|
||||||
USE_SUBSTITUTES="1"
|
USE_SUBSTITUTES="1"
|
||||||
USE_REMOTE_SUDO="1"
|
USE_REMOTE_SUDO="1"
|
||||||
|
AND_REBOOT=
|
||||||
|
|
||||||
ARGS=()
|
ARGS=()
|
||||||
OPTS=()
|
OPTS=()
|
||||||
@@ -43,6 +44,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
USE_REMOTE_SUDO=""
|
USE_REMOTE_SUDO=""
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--and-reboot)
|
||||||
|
AND_REBOOT="1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
OPTS=( "$@" )
|
OPTS=( "$@" )
|
||||||
@@ -106,9 +111,20 @@ if [[ -n "${ON_NEXT_BOOT}" ]]; then
|
|||||||
APPLY_OPERATION="boot"
|
APPLY_OPERATION="boot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
REBOOT_OPTS=()
|
||||||
|
|
||||||
|
if [[ -n "${USE_REMOTE_SUDO}" ]]; then
|
||||||
|
REBOOT_OPTS+=("sudo")
|
||||||
|
fi
|
||||||
|
|
||||||
|
REBOOT_OPTS+=("reboot")
|
||||||
|
|
||||||
case "${COMMAND}" in
|
case "${COMMAND}" in
|
||||||
apply)
|
apply)
|
||||||
nixos-rebuild "${APPLY_OPERATION}" --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" "${APPLY_OPTS[@]}"
|
nixos-rebuild "${APPLY_OPERATION}" --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" "${APPLY_OPTS[@]}"
|
||||||
|
if [[ -n "${AND_REBOOT}" ]]; then
|
||||||
|
ssh -t "${TARGET}" "${REBOOT_OPTS[@]}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
build)
|
build)
|
||||||
nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}"
|
nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}"
|
||||||
|
Reference in New Issue
Block a user