From c8676b05827bc4a764c355397c7f0622f5676798 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 29 Jul 2021 14:44:17 -0300 Subject: WIP reactivate nixvps with Terraform and nixos-rebuild on Vultr --- scripts/deploy | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'scripts/deploy') diff --git a/scripts/deploy b/scripts/deploy index 1b37888..d4a0128 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -1,9 +1,20 @@ #!/bin/sh set -eu +usage() { + cat <&2 + printf 'Missing HOSTNAME\n' >&2 + usage >&2 exit 2 fi @@ -15,17 +26,22 @@ fi DIR="$(dirname "$FILE")" -terraform apply "$DIR" +cd "$DIR" +. ./tf-env.sh +terraform init +terraform apply +cd - > /dev/null TLD="$(cat "$DIR"/tld.txt)" DIRS='/opt /srv' # shellcheck disable=2029 ssh "$TLD" "\ -sudo mkdir -p $DIRS && \ -sudo chown $USER:users -R $DIRS && \ -chmod -R 755 $DIRS" + sudo mkdir -p $DIRS && \ + sudo chown $USER:users -R $DIRS && \ + chmod -R 755 $DIRS +" -rsync -avzPL opt "$TLD":/ +rsync -avzPL opt "$DIR/opt" "$TLD":/ if [ -f "$DIR"/machines.scm ]; then guix deploy "$DIR"/machines.scm @@ -33,6 +49,6 @@ elif [ -f "$DIR"/configuration.nix ]; then scp "$DIR"/configuration.nix "$TLD":/etc/nixos/ ssh "$TLD" sudo nixos-rebuild switch else - printf 'Uknown OS type of "%s"\n' "$NAME" >&2 + printf 'Uknown deploy type for "%s"\n' "$NAME" >&2 exit 2 fi -- cgit v1.2.3