deploy-to_TEMPLATE.sh 1.69 KB
Newer Older
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
#!/bin/bash
#
# deployment script for reqesidta eid-server project
# michael rauh, tobias assmann
#
# This file acts as a template for creating a deploy script
# for a specific target environment. Please setup the env vars
# accourding to your needs:
#
# name of the target environment
ENV=stage
# the host of the target environment
HOST=localhost
# the user on the target environment used to copy the files there and run the project
USER=tobias
# the directory on the host of the target environment where
DIR=/home/tobias/Projects/reqesidta/deploy
#
#######################################################################################

# check for needed files
#

# check for needed commands
# local
command -v rsync >/dev/null 2>&1 || { echo >&2 "rsync is needed on locahost but it's not installed. Aborting."; exit 1; }
command -v ssh >/dev/null 2>&1 || { echo >&2 "ssh is needed on localhost but it's not installed. Aborting."; exit 1; }
# remote
ssh $USER@$HOST "command -v docker >/dev/null 2>&1" || { echo >&2 "docker is needed on $HOST but it's not installed. Aborting."; exit 1; }
ssh $USER@$HOST "command -v docker-compose >/dev/null 2>&1" || { echo >&2 "docker is needed on $HOST but it's not installed. Aborting."; exit 1; }

# synchronize this directory with the target on $HOST.
# exclude the not needed files
rsync -av --delete --progress \
	--exclude 'sam/config/ssa-server_TEMPLATE.conf' \
	--exclude 'docker-compose_TEMPLATE.yml' \
	--exclude 'deploy-to*' \
	--exclude 'readme*' \
	./ $USER@$HOST:$DIR

# Restart / re-build the services
#ssh $USER@$HOST "cd $DIR/ && docker-compose up -d --build"

echo "Deployment done, please wait until all services are fully running and proceed to EJBCA key setup."

exit 0;