-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdeploy-static
More file actions
executable file
·52 lines (39 loc) · 1.31 KB
/
deploy-static
File metadata and controls
executable file
·52 lines (39 loc) · 1.31 KB
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
#!/bin/bash
set -o errexit -o nounset -o pipefail
touch lock
exec {fd}< lock
if ! flock -n $fd; then
echo already processing/deploying static files >&2
exit 1
fi
./process-static $fd
. servers.sh
deploy() {
set -o errexit -o nounset -o pipefail
local server=$1
echo $server
local remote=root@$server
local active=$(ssh $remote readlink /srv/apps.grapheneos.org)
if [[ $active = /srv/apps.grapheneos.org_a ]]; then
local target=/srv/apps.grapheneos.org_b
else
local target=/srv/apps.grapheneos.org_a
fi
echo active is $active
echo target is $target
echo
ssh $remote "rm -rf $target && cp -a $active $target"
rsync -rptv --chmod=D755,F644 --progress --delete --fsync --preallocate static-tmp/ $remote:$target
ssh $remote "ln -snf $target /srv/apps.grapheneos.org && sync /srv/apps.grapheneos.org"
echo "root $target;" > $server.root_apps.grapheneos.org.conf
rsync -pcv --chmod=644 --fsync --preallocate $server.root_apps.grapheneos.org.conf $remote:/etc/nginx/root_apps.grapheneos.org.conf
rm $server.root_apps.grapheneos.org.conf
ssh $remote systemctl reload nginx
echo
echo active is now $target
echo
}
rm -f logs/*.log
export -f deploy
parallel "deploy {} >logs/{}.log 2>&1" ::: "${servers[@]}"
tail -n +1 logs/*.log