deploy: take target as optional argument

This commit is contained in:
lassulus 2015-06-14 20:57:19 +02:00
parent e59d4f45c0
commit cb70769a04
3 changed files with 20 additions and 17 deletions

View File

@ -1,23 +1,25 @@
#! /bin/sh #! /bin/sh
#
# copy-secrets system_name target
#
set -euf set -euf
host=$1 system_name=$1
target=$2
target=root@$host nixos_config=$config_root/modules/$system_name
secrets_nix=$secrets_root/$system_name/nix
nixos_config=$config_root/modules/$host secrets_rsync=$secrets_root/$system_name/rsync
secrets_nix=$secrets_root/$host/nix
secrets_rsync=$secrets_root/$host/rsync
if ! test -e "$secrets_rsync"; then if ! test -e "$secrets_rsync"; then
exit # nothing to do exit # nothing to do
fi fi
retiolum_secret=$(nixos-query $host services.retiolum.privateKeyFile) retiolum_secret=$(nixos-query $system_name services.retiolum.privateKeyFile)
retiolum_uid=$(nixos-query $host users.extraUsers.retiolum-tinc.uid) retiolum_uid=$(nixos-query $system_name users.extraUsers.retiolum-tinc.uid)
ejabberd_secret=/etc/ejabberd/ejabberd.pem ejabberd_secret=/etc/ejabberd/ejabberd.pem
ejabberd_uid=$(nixos-query $host users.extraUsers.ejabberd.uid) ejabberd_uid=$(nixos-query $system_name users.extraUsers.ejabberd.uid)
rsync -cz --chown=0:0 -vr "$secrets_rsync/" "$target:/" rsync -cz --chown=0:0 -vr "$secrets_rsync/" "$target:/"

View File

@ -1,16 +1,16 @@
#! /bin/sh #! /bin/sh
# #
# deploy # nixos-deploy system_name target
# #
set -euf set -euf
host=$1 system_name=$1
system=${2-$(nixos-build "$host")} target=$2
target=root@$host system=$(nixos-build "$system_name")
nix-copy-closure --gzip --to "$target" "$system" nix-copy-closure --gzip --to "$target" "$system"
copy-secrets "$host" copy-secrets "$system_name" "$target"
ssh ${NIX_SSHOPTS-} "$target" "$system/bin/switch-to-configuration" switch ssh ${NIX_SSHOPTS-} "$target" "$system/bin/switch-to-configuration" switch

7
deploy
View File

@ -1,10 +1,11 @@
#! /bin/sh #! /bin/sh
# #
# usage: ./deploy HOST # usage: ./deploy system_name [target]
# #
set -euf set -euf
host=$1 system_name=$1
target=${2-root@$system_name}
export PATH="$PWD/bin:$PATH" export PATH="$PWD/bin:$PATH"
#export nixpkgs=/var/nixpkgs #export nixpkgs=/var/nixpkgs
@ -13,4 +14,4 @@ export config_root=$PWD
export retiolum_hosts=$PWD/hosts export retiolum_hosts=$PWD/hosts
export secrets_root=$PWD/secrets export secrets_root=$PWD/secrets
exec nixos-deploy "$host" exec nixos-deploy "$system_name" "$target"