1
1
#! /usr/bin/env bash
2
2
source lib/config.shlib; # load the config library functions
3
+ source lib/dockertags.shlib # load docker functions.
3
4
4
5
# Check if docker is running
5
6
if ! docker info > /dev/null 2>&1 ; then
@@ -14,10 +15,14 @@ frontendname="FileFighterFrontend"
14
15
dbname=" FileFighterDB"
15
16
networkname=" FileFighterNetwork"
16
17
18
+ # latest stable versions.
19
+ frontendVersion=" latest" # "$(getTagsByName filefighter/frontend v | tail -1)"
20
+ restVersion=" latest" # $(getTagsByName filefighter/rest v | tail -1)"
21
+
17
22
# Startup Message.
18
23
echo " "
19
24
echo " -------------------------< FileFighter >--------------------------"
20
- echo " | Version 0.0.1 last updated at 14.10.20 |"
25
+ echo " | Version 0.0.1. Last updated at 14.10.20 |"
21
26
echo " | Developed by Gimleux, Valentin, Open-Schnick. |"
22
27
echo " | Development Blog: https://filefighter.github.io |"
23
28
echo " | The code can be found at: https://www.github.com/filefighter |"
@@ -33,45 +38,60 @@ db_port="$(read ./config.cfg db_port)"
33
38
db_name=" $( read ./config.cfg db_name) "
34
39
db_user=" $( read ./config.cfg db_user) "
35
40
db_password=" $( read ./config.cfg db_password) "
41
+ use_stable_versions=" $( read ./config.cfg use_stable_versions) "
36
42
37
43
if ! [[ $frontend_port ]]; then
38
44
echo " Config for frontend_port not found, using defaults."
39
- frontend_port=" $( read ./config.cfg frontend_port) "
45
+ frontend_port=" $( read ./config.cfg.defaults frontend_port) "
40
46
fi
41
47
42
48
if ! [[ $rest_port ]]; then
43
49
echo " Config for rest_port not found, using defaults."
44
- rest_port=" $( read ./config.cfg rest_port) "
50
+ rest_port=" $( read ./config.cfg.defaults rest_port) "
45
51
fi
46
52
47
53
if ! [[ $db_port ]]; then
48
54
echo " Config for db_port not found, using defaults."
49
- db_port=" $( read ./config.cfg db_port) "
55
+ db_port=" $( read ./config.cfg.defaults db_port) "
50
56
fi
51
57
52
58
if ! [[ $db_name ]]; then
53
59
echo " Config for db_name not found, using defaults."
54
- db_name=" $( read ./config.cfg db_name) "
60
+ db_name=" $( read ./config.cfg.defaults db_name) "
55
61
fi
56
62
57
63
if ! [[ $db_user ]]; then
58
64
echo " Config for db_user not found, using defaults."
59
- db_user=" $( read ./config.cfg db_user) "
65
+ db_user=" $( read ./config.cfg.defaults db_user) "
60
66
fi
61
67
62
68
if ! [[ $db_password ]]; then
63
69
echo " Config for db_password not found, using defaults."
64
- db_password=" $( read ./config.cfg db_password) "
70
+ db_password=" $( read ./config.cfg.defaults db_password) "
71
+ fi
72
+
73
+ if ! [[ $use_stable_versions ]]; then
74
+ echo " Config for use_stable_versions not found, using defaults."
75
+ use_stable_versions=" $( read ./config.cfg.defaults use_stable_versions) "
65
76
fi
66
77
67
78
# Check if (default) password was empty.
68
79
if ! [[ $db_password ]]; then
69
80
# Create new Password
70
81
echo " Creating new random password for the database."
71
- db_password=" asdasdasd "
82
+ db_password=$( wget -qO- " https://www.passwordrandom.com/query?command=password&scheme=rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr " )
72
83
write $configFilePath db_password $db_password
73
84
fi
74
85
86
+ # Check versions config
87
+ if [[ $use_stable_versions == " true" ]]; then
88
+ echo " Installing stable versions."
89
+ frontendVersion=" $( getTagsByName filefighter/frontend v | tail -1) "
90
+ restVersion=" $( getTagsByName filefighter/rest v | tail -1) "
91
+ else
92
+ echo " Installing latest versions. Be aware that minor bugs could occur. Please report found bugs: [email protected] ."
93
+ fi
94
+
75
95
# Finished Config:
76
96
echo " Finished reading config. Building containers..."
77
97
@@ -90,7 +110,7 @@ echo "Creating necessary network."
90
110
docker network create $networkname > /dev/null 2>&1
91
111
92
112
# Database
93
- echo " Creating latest DB Container."
113
+ echo " Creating DB Container, with tag: latest ."
94
114
docker create \
95
115
-e MONGO_INITDB=$db_name \
96
116
-e MONGO_INITDB_ROOT_USERNAME=$db_user \
@@ -102,7 +122,7 @@ docker start $dbname >/dev/null 2>&1
102
122
sleep 3 # waiting 3 seconds for mongo to start.
103
123
104
124
# REST APP
105
- echo " Creating latest REST Container."
125
+ echo " Creating REST Container, with tag: $restVersion ."
106
126
docker create \
107
127
-e DB_USERNAME=$db_user \
108
128
-e DB_PASSWORD=$db_password \
@@ -111,15 +131,15 @@ docker create \
111
131
-e SPRING_PROFILES_ACTIVE=" prod" \
112
132
-p $rest_port :8080 \
113
133
--network $networkname \
114
- --name $restname filefighter/rest:latest > /dev/null 2>&1
134
+ --name $restname filefighter/rest:$restVersion > /dev/null 2>&1
115
135
docker start $restname > /dev/null 2>&1
116
136
117
137
# Frontend
118
- echo " Creating latest Frontend Container."
138
+ echo " Creating Frontend Container, with tag: $frontendVersion ."
119
139
docker create \
120
140
-e REST_PORT=$rest_port \
121
141
-p $frontend_port :5000 \
122
- --name $frontendname filefighter/frontend:latest > /dev/null 2>&1
142
+ --name $frontendname filefighter/frontend:$frontendVersion > /dev/null 2>&1
123
143
docker start $frontendname > /dev/null 2>&1
124
144
125
145
# DataHandler
0 commit comments