-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
68 lines (57 loc) · 1.59 KB
/
setup.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
66
67
68
#!/bin/bash
# Checking root rights
if (( $EUID != 0 )); then
echo "Please run as root"
exit
fi
# Preparing graylog .env file
echo Preparing graylog .env file
echo -----------------------
echo Enter server ip address
read -p 'server ip:' IP
echo Enter graylog Admin password:
read -p 'password: ' ADM_PWD
PWD_SHA=$(echo $ADM_PWD | head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1)
echo Enter timezone '(Canonical ID)' Full list available at https://www.joda.org/joda-time/timezones.html
read -p '' TZ
if ! [ -x "$(command -v pwgen)" ]; then
echo Enter Graylog secret '(at least 16 symbol)'
read -p '' SECRET
else
SECRET=$(pwgen -N 1 -s 18)
fi
echo .env file created with next parameters:
echo
echo
echo
cat <<EOF | tee .env
uri=http://$IP:9000/
es_host=http://elasticsearch:9200
mongo_uri=mongodb://mongodb:27017/graylog
admin_password=$PWD_SHA
secret='$SECRET'
timezone=$TZ
EOF
echo
echo
echo
# Preparing Graylog journal folder
mkdir journal && chown -R 1100:1100 journal/
# Preparing ElasticSearch folder
mkdir data && chmod g+rwx data && chown 1000:1000 data
# Preparing docker images
echo Pulling docker images
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.2
docker pull graylog/graylog:5.0
docker pull mongo:6
# Preparing systcl config
if grep -q vm.max_map_count /etc/sysctl.conf; then
echo 'Sysctl config ok'
echo
echo "All that's left is to accomplish: docker-compose up -d"
else
echo 'Fixing sysctl config'
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
echo
echo "All that's left is to accomplish: docker-compose up -d"
fi