forked from berenjian/Salav.at
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·60 lines (45 loc) · 1007 Bytes
/
deploy.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
#!/usr/bin/env bash
set -Eeuo pipefail
trap "echo '❌ Error'" ERR
thisPath="$(pwd)"
echoStep () {
echo "🔹 $1"
}
error () {
echo "❌ $1"
exit 1
}
remoteShell () {
server=$1; shift;
echoStep "remoteShell"
ssh $server -tt $@
}
servicePath="/srv/salav.at"
syncFolder () {
server=$1; shift;
echoStep "syncFolder"
remoteShell $server "mkdir -p $servicePath"
echoStep "Uploading ..."
rsync \
-Pazzh --delete \
./server/ $server:$servicePath/
}
syncAndUp () {
server=$1; shift;
echoStep "syncAndUp"
syncFolder $server
remoteShell $server "cd $servicePath; chmod +x _up.sh; ./_up.sh"
}
dcDown () {
server=$1; shift;
echoStep "Down service"
remoteShell $server "cd $servicePath; docker-compose ps; docker-compose down --remove-orphans; docker-compose ps"
}
echoStep "sync: Starting ..."
if [[ "${1:-}" == "--down" ]]
then
dcDown [email protected]
else
syncAndUp [email protected]
fi
echoStep "sync: done"