-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-dragonmind.sh
executable file
·71 lines (52 loc) · 1.68 KB
/
deploy-dragonmind.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# takes the already built tar file in dragonmind/build/distributions/
# and does a fresh (re)install of it on the given target machine
# (or a default if no target) to which we must be able to ssh
# so make sure the username for the target host is in the ssh config.
# usage deploy-dragonmind.sh [<target machine> [<target user>]]
# TODO move to scripts/
# config
target_machine=${1:-tiger.local}
#target_machine=${1:-silverbox.local}
#target_machine=192.168.1.112
deploy_dir=dragonmind
archive_dir=archive
shopt -s failglob
cd "$( dirname "${BASH_SOURCE[0]}" )"
source functions.sh
# convenience variables
ssh_target=${target_machine}
unixtime=`date +%s`
# changes foreground colour so unexpected stdout from following command can be visually distnct
function yy() {
printf " \\033[33m"
}
#main
deployable=dragonmind/build/distributions/dragonmind-*.tar
echo -n locating deployable ${deployable}
yy
test -f $deployable && ok || die
echo build timestamp $unixtime
echo -n verifying connectivity to $target_machine
yy
ping -c 1 $target_machine 2>&1 >/dev/null && ok || die
echo -n testing ssh
yy
ssh $ssh_target mkdir -p $archive_dir && ok || die
echo -n deploying $deployable
yy
rsync -q $deployable $ssh_target: && ok || die
fname=`basename $deployable`
echo -n syncing video dir
yy
rsync -qazu --delete-after dragonmind/video/ $ssh_target:video && ok || die
ddir=`basename -s .tar $deployable`
echo -n removing existing distribution directory $ddir
yy
ssh $ssh_target "mkdir -p $ddir && rm -r \"$ddir\"" && ok || die
echo -n unarchiving $fname
yy
ssh $ssh_target "tar -xf $fname" && ok || die
echo -n linking video dir
yy
ssh $ssh_target "ln -sf ~/video $ddir" && ok || die