forked from abersailbot/dewi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy
More file actions
executable file
·45 lines (35 loc) · 845 Bytes
/
deploy
File metadata and controls
executable file
·45 lines (35 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -xe
if [ "$#" -ne 1 ]; then
command="redeploy"
if [ "$#" -ne 2 ]; then
echo "Not enough arguments. Usage: $0 <hostname> or $0 <hostname> provision"
exit 1
else
command=$2
fi
fi
host=$1
function check_ssh () {
status=$(ssh -q $host echo ok 2>&1)
if [[ $status == ok ]] ; then
echo "Can connect using ssh"
else
echo "Can't connect with ssh to host $host"
exit 1
fi
}
function run () {
cmd=$1
ssh $host $cmd
}
check_ssh
run "mkdir -vp ~/dewi"
# install rsync
run "sudo apt-get install rsync"
# copy local files
rsync -va --no-inc-recursive --delete --max-size=10M --exclude 'dewi-hardware' ./ $host:~/dewi
if [ "$command" = "provision" ]; then
run "cd ~/dewi; sudo ./host-provision"
fi
run "cd ~/dewi; sudo ./host-deploy"