diff options
author | EuAndreh <eu@euandre.org> | 2021-07-29 14:44:17 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-07-29 14:50:25 -0300 |
commit | c8676b05827bc4a764c355397c7f0622f5676798 (patch) | |
tree | 03fc522c39bb834d1032ed5dd3d25598e2c66dd3 /scripts/deploy | |
parent | cd servers && git mv discussions-site/ guixvps/ mailbug/ mediator/ multipatch... (diff) | |
download | toph-c8676b05827bc4a764c355397c7f0622f5676798.tar.gz toph-c8676b05827bc4a764c355397c7f0622f5676798.tar.xz |
WIP reactivate nixvps with Terraform and nixos-rebuild on Vultr
Diffstat (limited to 'scripts/deploy')
-rwxr-xr-x | scripts/deploy | 30 |
1 files changed, 23 insertions, 7 deletions
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 <<EOF +Usage: + $0 HOSTNAME + +Examples: + $0 kuvira +EOF +} + NAME="${1:-}" if [ -z "$NAME" ]; then - printf 'Missing hostname\n' >&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 |