on bbf0a09 help sign in
obelisk/deploy
26 lines 671 B history raw
1#!/usr/bin/env bash
2set -eux
4DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6HOSTNAME="$1"
7shift
8CONFIG="$1"
9shift
11# Check preconditions
12#diff <(ls ../config) <(ls config) # We don't want to deploy if we have the wrong set of config files
14eval "$(ssh-agent)"
15ssh-add "$CONFIG/ssh_key"
17RESULT="$(nix-build --no-out-link -A completeServer.aws.system --argstr hostName "$HOSTNAME" "$@")"
19nix-copy-closure -v --to root@"$HOSTNAME" --gzip "$RESULT"
21"$DIR/deploy-config" "ssh" root@"$HOSTNAME" "$CONFIG"
23ssh root@"$HOSTNAME" bash -x <<EOF
24nix-env -p /nix/var/nix/profiles/system --set "$RESULT"
25/nix/var/nix/profiles/system/bin/switch-to-configuration switch
26EOF