summaryrefslogtreecommitdiff
path: root/nixos/profiles/workstation/scripts/deploy-dir
blob: f90a4ae711e197f27ad29d4e7e8b1f6489821be4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash
# Replaces the contents of a remote directory with the contents of a local directory.

if [ "$#" -ne 3 ]; then
    echo "usage: $0 <local_dir> <ssh_dest> <remote_dir>"
    exit 1
fi
printf -v remote_dir %q $3

cd $1
tar cf - . | ssh $2 "set -xe
TEMP_DIR=\$(mktemp -d)
cd \$TEMP_DIR
tar xvf -
rm -rf $remote_dir
mv \$TEMP_DIR $remote_dir
"