This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
forked from wazuh/wazuh
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gen_ossec.sh
executable file
·118 lines (100 loc) · 2.73 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
#!/bin/sh
# Wazuh Configuration & Init Files Generator
# Copyright (C) 2016 Wazuh Inc.
# November 24, 2016.
#
# This program is a 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`
# Read script values
if [ "$1" = "conf" ]; then
. ./src/init/shared.sh
. ./src/init/inst-functions.sh
if [ "$#" = "4" ]; then
INSTYPE="$2"
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
elif [ "$#" = "3" ]; then
INSTYPE="$2"
DIST_NAME=$(echo $3 | tr '[:upper:]' '[:lower:]')
DIST_VER="0"
DIST_SUBVER="0"
else
echo " USE: ./gen_ossec.sh conf install_type distribution [version]"
echo " - install_type: manager, agent"
echo " - distribution: redhat, debian, ..."
exit 1
fi
# Default values definition
SERVER_IP="MANAGER_IP"
NEWCONFIG="./ossec.conf.temp"
SYSCHECK="yes"
ROOTCHECK="yes"
OPENSCAP="yes"
ACTIVERESPONSE="yes"
RLOG="no" # syslog
SLOG="yes" # remote
if [ -r "$NEWCONFIG" ]; then
rm "$NEWCONFIG"
fi
if [ "$INSTYPE" = "manager" ]; then
WriteManager "no_localfiles"
elif [ "$INSTYPE" = "agent" ]; then
WriteAgent "no_localfiles"
else
echo " USE: ./gen_ossec.sh conf install_type distribution [version]"
echo " - install_type: manager, agent"
echo " - distribution: redhat, debian, ..."
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 [ "$#" = "2" ]; then
INSTYPE=$(echo $2 | tr '[:upper:]' '[:lower:]')
if [ "$INSTYPE" = "manager" ]; then
INSTYPE="server"
fi
else
echo " USE: ./gen_ossec.sh install_type"
echo " - install_type: manager, agent"
exit 1
fi
GenerateInitConf
exit 0
else
echo ""
echo "Wazuh Configuration & Init Files Generator"
echo ""
echo " Generate a default ossec.conf file."
echo " USE: ./gen_ossec.sh conf install_type distribution [version]"
echo " - install_type: manager, agent"
echo " - distribution: redhat, debian, ..."
echo ""
echo " Generate a default ossec-init.conf file."
echo " USE: ./gen_ossec.sh init install_type"
echo " - install_type: manager, agent"
echo ""
exit 1
fi