-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions-linux.sh
65 lines (58 loc) · 2.49 KB
/
functions-linux.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
61
62
63
64
65
################################################################################
# FUNCTIONS
################################################################################
# create filebeat container
function create_filebeat(){
if [ $1 != true ]
then
return 0
fi
echo "Create filebeat configuration..."
mkdir -p ${BASEDIR}/fb
cp ./filebeat/filebeat.yml.template ./filebeat/filebeat.yml
#configuration
sed -i 's/%CONF_INSTANCEPREFIX%/'"$CONF_INSTANCEPREFIX"'/g' ./filebeat/filebeat.yml
cp -r ./filebeat/* ${BASEDIR}/fb/
rm ${BASEDIR}/fb/filebeat.yml.template
}
# Create elastic, kibana and nginx containers
function create_es_ki_ng(){
echo "Create elastic, kibana and nginx configurations..."
#Create the folders for the persistant data
mkdir -p ${BASEDIR}
mkdir -p ${BASEDIR}/es/config
mkdir -p ${BASEDIR}/es/config/data/nodes
mkdir -p ${BASEDIR}/nginx
cp ./nginx/default.conf.template ./nginx/default.conf
cp ./elasticsearch/elasticsearch.yml.template ./elasticsearch/elasticsearch.yml
#docker-compose
sed -i 's/%BASEDIR%/'"$CONF_BASEDIR"'/g' docker-compose.yml
sed -i 's/%CONF_INSTANCEPREFIX%/'"$CONF_INSTANCEPREFIX"'/g' docker-compose.yml
sed -i 's/%CONF_ESPORT%/'"$CONF_ESPORT"'/g' docker-compose.yml
sed -i 's/%CONF_KIPORT%/'"$CONF_KIPORT"'/g' docker-compose.yml
sed -i 's/%CONF_TIMEZONE%/'"$CONF_TIMEZONE"'/g' docker-compose.yml
#nginx config
sed -i 's/%CONF_SERVERNAME%/'"$CONF_SERVERNAME"'/g' ./nginx/default.conf
sed -i 's/%CONF_INSTANCEPREFIX%/'"$CONF_INSTANCEPREFIX"'/g' ./nginx/default.conf
sed -i 's/%CONF_ESPORT%/'"$CONF_ESPORT"'/g' ./nginx/default.conf
sed -i 's/%CONF_KIPORT%/'"$CONF_KIPORT"'/g' ./nginx/default.conf
printf "${KIADMIN}:$(openssl passwd -crypt ${KIPASSWD})" > ${BASEDIR}/nginx/.ki_htpasswd
printf "${ESADMIN}:$(openssl passwd -crypt ${ESPASSWD})" > ${BASEDIR}/nginx/.es_htpasswd
#elasticsearch
sed -i 's/%CONF_INSTANCEPREFIX%/'"$CONF_INSTANCEPREFIX"'/g' ./elasticsearch/elasticsearch.yml
#Copy files with settings to the persistant folder
cp -r ./elasticsearch/* ${BASEDIR}/es/config/
rm ${BASEDIR}/es/config/elasticsearch.yml.template
rm ./elasticsearch/elasticsearch.yml
mv ./nginx/default.conf ${BASEDIR}/nginx/
}
# create docer-compose.yml file
function setup_compose(){
echo "Create docker-compose.yml file from the template..."
if [ $1 = true ]
then
cat docker-compose.yml.template docker-compose.filebeat.template > docker-compose.yml
else
cp docker-compose.yml.template docker-compose.yml
fi
}