-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
deploy-server
executable file
·36 lines (28 loc) · 849 Bytes
/
deploy-server
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
#!/bin/bash
set -o errexit -o nounset -o pipefail
touch lock-server
exec {fd}< lock-server
if ! flock -n $fd; then
echo already deploying server >&2
exit 1
fi
rm -rf build
./gradlew build
path=/opt/attestation
active=$(ssh $remote readlink $path/deploy)
if [[ $active = $path/deploy_a ]]; then
target=$path/deploy_b
else
target=$path/deploy_a
fi
echo
echo active is $active
echo target is $target
echo
ssh $remote "rm -rf $target && cp -a $active $target"
rsync -prcv --chmod=D755,F644 --fsync --preallocate systemd/system/ $remote:/etc/systemd/system
rsync -prcv --chmod=D755,F644 --delete --fsync --preallocate build/libs/ $remote:$target
ssh $remote "ln -snf $target $path/deploy && sync $path/deploy && systemctl daemon-reload && systemctl restart attestation"
echo
echo active is now $target