refector
This commit is contained in:
parent
42f15beccf
commit
ed42006971
21 changed files with 271 additions and 366 deletions
|
|
@ -6,16 +6,40 @@ pkgs.writeShellApplication {
|
|||
nix-output-monitor
|
||||
openssh
|
||||
coreutils
|
||||
nix
|
||||
attic-client
|
||||
];
|
||||
|
||||
text = ''
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
TARGET_NAME=""
|
||||
if [ $# -gt 0 ]; then
|
||||
TARGET_NAME="$1"
|
||||
fi
|
||||
FLAKE_PATH="."
|
||||
UPLOAD_CACHE=false
|
||||
MAX_JOBS="''${NIX_BUILD_MAX_JOBS:-4}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--upload) UPLOAD_CACHE=true ;;
|
||||
--no-upload) UPLOAD_CACHE=false ;;
|
||||
--help|-h)
|
||||
echo "사용법: nrr <호스트명> [--upload|--no-upload]"
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
echo "알 수 없는 옵션입니다: $1" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
if [ -n "$TARGET_NAME" ]; then
|
||||
echo "호스트명은 하나만 지정할 수 있습니다." >&2
|
||||
exit 2
|
||||
fi
|
||||
TARGET_NAME="$1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
declare -A HOST_MAP
|
||||
HOST_MAP["hikari"]="10.11.8.100"
|
||||
|
|
@ -43,17 +67,20 @@ pkgs.writeShellApplication {
|
|||
fi
|
||||
|
||||
echo "시스템 빌드 중..."
|
||||
BUILD_PATH=$(nom build "$FLAKE_PATH#nixosConfigurations.$TARGET_NAME.config.system.build.toplevel" --print-out-paths --no-link --eval-cache --accept-flake-config)
|
||||
BUILD_PATH=$(nom build "$FLAKE_PATH#nixosConfigurations.$TARGET_NAME.config.system.build.toplevel" \
|
||||
--max-jobs "$MAX_JOBS" --print-out-paths --no-link)
|
||||
|
||||
echo "시스템 복사 중... ($BUILD_PATH -> $TARGET_IP)"
|
||||
nix copy --to "ssh://imnyang@$TARGET_IP" "$BUILD_PATH"
|
||||
nix copy --substitute-on-destination --to "ssh://imnyang@$TARGET_IP" "$BUILD_PATH"
|
||||
|
||||
echo "스위치 중..."
|
||||
# shellcheck disable=SC2029
|
||||
ssh "imnyang@$TARGET_IP" "sudo nix-env --profile /nix/var/nix/profiles/system --set \"$BUILD_PATH\" && sudo $BUILD_PATH/bin/switch-to-configuration switch"
|
||||
|
||||
echo "캐시 업로드 중..."
|
||||
attic push imnyang "$BUILD_PATH" || echo "푸시 실패"
|
||||
if [ "$UPLOAD_CACHE" = true ]; then
|
||||
echo "캐시 업로드 중..."
|
||||
attic push imnyang "$BUILD_PATH" || echo "푸시 실패"
|
||||
fi
|
||||
|
||||
echo "배포 완료!"
|
||||
'';
|
||||
|
|
|
|||
Loading…
Reference in a new issue