forked from wazuh/wazuh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_ossec.sh
executable file
·136 lines (116 loc) · 2.9 KB
/
gen_ossec.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
# Wazuh Configuration & Init Files Generator
# Copyright (C) 2015-2019, Wazuh Inc.
# November 24, 2016.
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
# File dependencies:
# ./src/init/shared.sh
# ./src/init/inst-functions.sh
# ./src/init/template-select.sh
# ./src/init/dist-detect.sh
# ./src/VERSION
# ./src/LOCATION
# ./etc/templates/config
# Looking up for the execution directory
cd `dirname $0`
Conf_Use()
{
echo " USE: ./gen_ossec.sh conf install_type distribution version [installation_path]"
echo " - install_type: manager, agent, local"
echo " - distribution: rhel, debian, ubuntu, ..."
echo " - version: 6, 7, 16.04, ..."
echo " - installation_path (optional): changes the default path '/var/ossec' "
}
Init_Use()
{
echo " USE: ./gen_ossec.sh init install_type [installation_path]"
echo " - install_type: manager, agent, local"
echo " - installation_path (optional): changes the default path '/var/ossec' "
}
# Read script values
if [ "$1" = "conf" ]; then
. ./src/init/shared.sh
. ./src/init/inst-functions.sh
if [ "$#" -ge "4" ]; then
INSTYPE=$(echo $2 | tr '[:upper:]' '[:lower:]')
if [ "$INSTYPE" = "manager" ]; then
INSTYPE="server"
fi
DIST_NAME=$(echo $3 | tr '[:upper:]' '[:lower:]')
if [ $(echo $4 | grep "\.") ]; then
DIST_VER=$(echo $4 | cut -d\. -f1)
DIST_SUBVER=$(echo $4 | cut -d\. -f2)
else
DIST_VER="$4"
DIST_SUBVER="0"
fi
if [ "$#" = "5" ]; then
INSTALLDIR="$5"
fi
else
Conf_Use
exit 1
fi
# Default values definition
SERVER_IP="MANAGER_IP"
NEWCONFIG="./ossec.conf.temp"
SYSCHECK="yes"
ROOTCHECK="yes"
OPENSCAP="yes"
SYSCOLLECTOR="yes"
SECURITY_CONFIGURATION_ASSESSMENT="yes"
ACTIVERESPONSE="yes"
AUTHD="yes"
SSL_CERT="yes"
RLOG="no" # syslog
SLOG="yes" # remote
if [ -r "$NEWCONFIG" ]; then
rm "$NEWCONFIG"
fi
if [ "$INSTYPE" = "server" ]; then
WriteManager "no_localfiles"
elif [ "$INSTYPE" = "agent" ]; then
WriteAgent "no_localfiles"
elif [ "$INSTYPE" = "local" ]; then
WriteLocal "no_localfiles"
else
Conf_Use
exit 1
fi
cat "$NEWCONFIG"
rm "$NEWCONFIG"
exit 0
elif [ "$1" = "init" ]; then
. ./src/init/inst-functions.sh
. ./src/init/shared.sh
# Read script values
if [ "$#" -ge "2" ]; then
INSTYPE=$(echo $2 | tr '[:upper:]' '[:lower:]')
if [ "$INSTYPE" = "manager" ]; then
INSTYPE="server"
fi
if [ "$#" = "3" ]; then
INSTALLDIR="$3"
fi
else
Init_Use
exit 1
fi
GenerateInitConf
exit 0
else
echo ""
echo "Wazuh Configuration & Init Files Generator"
echo ""
echo " Generate a default ossec.conf file."
Conf_Use
echo ""
echo " Generate a default ossec-init.conf file."
Init_Use
echo ""
exit 1
fi