-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-epk.sh
91 lines (71 loc) · 2.25 KB
/
setup-epk.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
COPIEDFILES=0
######
APPPATH=/opt/containers/parsedmarc-docker/parsedmarc/conf
FILE=parsedmarc.ini
echo "Check if the file $FILE already exist.";
if [ ! -f $APPPATH/$FILE ]; then
echo "File $FILE was created successfully.";
echo
/bin/cp $APPPATH/parsedmarc.ini.example $APPPATH/$FILE
COPIEDFILES=$((COPIEDFILES + 1))
else
echo "File $FILE already exist!";
echo
fi
######
APPPATH=/opt/containers/parsedmarc-docker
FILE=docker-compose.yml
echo "Check if the file docker-compose.yml already exist.";
if [ ! -f $APPPATH/$FILE ]; then
echo "File $FILE was created successfully.";
/bin/cp $APPPATH/docker-compose.yml.example $APPPATH/$FILE
COPIEDFILES=$((COPIEDFILES + 1))
else
echo "File $FILE already exist.";
fi
echo
######
APPPATH=/opt/containers/parsedmarc-docker
FILE=.env
echo "Check if the file .env already exist.";
if [ ! -f $APPPATH/$FILE ]; then
echo "File $FILE was created successfully.";
/bin/cp $APPPATH/.env.example $APPPATH/$FILE
COPIEDFILES=$((COPIEDFILES + 1))
else
echo "File $FILE already exist.";
fi
echo
######
if [[ "$COPIEDFILES" -eq "3" ]]; then
echo "Set random password for the user elastic.";
password=$(/bin/tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | /bin/head -c 20)
/bin/sed -i 's/<your-elastic-password>/'$password'/g' /$APPPATH/$FILE
echo "Set random password for the user kibana_system.";
password=$(/bin/tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | /bin/head -c 20)
/bin/sed -i 's/<your-kibana-password>/'$password'/g' /$APPPATH/$FILE
echo "Set random password for the user parsedmarc.";
password=$(/bin/tr -dc 'A-Za-z0-9!?=' < /dev/urandom | /bin/head -c 20)
/bin/sed -i 's/<your-parsedmarc-password>/'$password'/g' /$APPPATH/$FILE
/bin/sed -i 's/<your-parsedmarc-password>/'$password'/g' /$APPPATH/parsedmarc/conf/parsedmarc.ini
fi
######
echo "Create logrotate config file.";
cat << \EOF > /etc/logrotate.d/parsedmarc
/opt/containers/parsedmarc-docker/parsedmarc/log/*.log {
rotate 31
daily
compress
missingok
delaycompress
dateext
sharedscripts
postrotate
cd /opt/containers/parsedmarc-docker \
&& /usr/bin/docker compose restart parsedmarc
endscript
}
EOF
echo
echo "The script has reached the end.";