deploy.sh 2.31 KB
Newer Older
1
2
3
#!/bin/bash
#
# deployment script for reqesidta eid-server project
4
# tobias.assmann@ecsec.de
5
6
7
8
9
#
# 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:
#
10
# the user on the target host used to copy the files there and run the project
11
12
13
USER=TARGET_USER
# the target host of the deployment
HOST=TARGET_HOST
14
# the directory on the target host where to put the project
15
DIR=TARGET_DIR
16
17
18
#
#######################################################################################

19
20
21
22
23
24
25
26
27
28
echo "check for correct replacement ..."
! grep TARGET_ ./docker-compose.yml || { echo >&2 "Found text to be replaced in docker-compose.yml. Aborting."; exit 1; }
! grep TARGET_ ./ssa/config/ssa-server.conf || { echo >&2 "Found text to be replaced in ssa-server.conf. Aborting."; exit 1; }
! test $HOST = "TARGET_HOST" || { echo >&2 "Found text TARGET_HOST to be replaced in deploy.sh. Aborting."; exit 1; }
! test $USER = "TARGET_USER" || { echo >&2 "Found text TARGET_USER to be replaced in deploy.sh. Aborting."; exit 1; }
! test $DIR = "TARGET_DIR" || { echo >&2 "Found text TARGET_DIR be replaced in deploy.sh. Aborting."; exit 1; }

echo "check target environment ..."
ssh $USER@$HOST "cd $DIR >/dev/null 2>&1" || { echo >&2 "Could not reach $DIR as user $USER on $HOST Aborting."; exit 1; }

29
30
echo "check for needed commands ..."
command -v rsync >/dev/null 2>&1 || { echo >&2 "rsync is needed on localhost but it's not installed. Aborting."; exit 1; }
31
32
33
34
command -v ssh >/dev/null 2>&1 || { echo >&2 "ssh is needed on localhost but it's not installed. Aborting."; exit 1; }
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; }

35
echo "copy files to server ..."
36
rsync -av --delete --progress \
37
38
39
	--exclude 'deploy.sh' \
	--exclude 'poseidas-configuration-wizard.jar' \
	--exclude 'readme.md' \
40
41
	./ $USER@$HOST:$DIR

42
echo "Build and start services on server ..."
43
ssh $USER@$HOST "cd $DIR/ && docker-compose up -d --build"
44
echo $?
45

46
echo "Deployment done, please wait until all services are fully running without heavy load and then proceed with EJBCA key setup."
47

48
exit 0