-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-server.sh
executable file
·54 lines (45 loc) · 1.41 KB
/
setup-server.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
#!/usr/bin/env bash
# Colors
green=`tput setaf 2`
red=`tput setaf 1`
yellow=`tput setaf 3`
blue=`tput setaf 4`
reset=`tput sgr0`
CURRENT_SCRIPT=$(basename "$0")
source .env
echo ""
echo "${red}##### GIT + SSHD SERVER ${VERSION} #####${yellow}"
echo ""
date
echo ""
echo "${green}* Setting up a Git Server"
echo ""
echo "${red}==========--------- Building the new docker image -----------=========="
echo ""
echo "${green}* docker-compose build${yellow}"
echo ""
docker-compose build
echo ""
DOCKER_IMAGE=$(docker-compose config | grep image: | awk '{print $2}')
echo "${red}==========--------- Start a new Git Server -----------=========="
echo ""
echo "${green}* docker-compose up -d${yellow}"
echo ""
docker-compose stop && docker-compose up -d
echo ""
GIT_PEM_PATH=$(pwd)/.id_rsa_from_git_server
CONTAINER_NAME=$(docker ps --format '{{.Names}}' | grep git-ssh)
echo "${red}==========--------- Copying credentials from Git server Container -----------=========="
echo ""
echo "${green}* Copying the key file ${yellow}id_rsa private${green} from the Git Server"
echo "${yellow}* docker cp ${CONTAINER_NAME}:/home/git/.ssh/id_rsa ${GIT_PEM_PATH}"
echo ""
docker cp ${CONTAINER_NAME}:/home/git/.ssh/id_rsa ${GIT_PEM_PATH}
echo ""
date
echo "${green}"
echo "* Finished setting up the server..."
echo "* Now you can run tests with test.sh copying the command below:"
echo ""
echo "${yellow}GIT_PEM_PATH=${GIT_PEM_PATH} ./test.sh"
echo ""