-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlib-component-nsm.sh
More file actions
169 lines (145 loc) · 4.57 KB
/
Copy pathlib-component-nsm.sh
File metadata and controls
169 lines (145 loc) · 4.57 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
#
# Copyright (C) 2008-2009 SecurixLive <dev@securixlive.com>
#
# 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 Free Software Foundation. You may not use, modify or
# distribute this program under any other version of the GNU General
# Public License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Description:
# Handling of the installation, configuration, fixing and uninstallation of
# the sguil-server package and dependancies.
#
# Dependencies:
#
NSMNOW_PATH="."
nsm_package_nsm_required_options()
{
# grab input variables with sane defaulting
OPTIONS=${1:-1}
if [ ${OPTIONS} -eq 1 ]
then
required_option_set "GENERAL_SOURCE_DIR"
required_option_set "GENERAL_BIN_DIR"
required_option_set "GENERAL_SBIN_DIR"
required_option_set "GENERAL_LIB_DIR"
required_option_set "GENERAL_ETC_DIR"
required_option_set "GENERAL_INIT_DIR"
required_option_set "GENERAL_CRON_DIR"
fi
return 0
}
nsm_package_nsm_download()
{
print_all "nsm has no download options enabled" 2
}
nsm_package_nsm_reconfigure()
{
print_all "nsm has no reconfigure options enabled" 2
}
nsm_package_nsm_fix()
{
print_all "nsm has no fix options enabled" 2
}
nsm_package_nsm_install()
{
# always install (there is NO harm in this)
print_all "Installing nsm" 2
#
# NSMnow
#
# install NSMnow library file(s)
print_all "Copying library file(s)" 3
copy_and_cache_files "${NSMNOW_PATH}/lib" "*" "${GENERAL_LIB_DIR}/nsmnow" "" "" "nsmnow"
if [ ${?} -ne 0 ]
then
return 1
fi
# install NSMnow binary file(s)
print_all "Copying binary file(s)" 3
copy_and_cache_files "${NSMNOW_PATH}" "NSMnow" "${GENERAL_SBIN_DIR}" "" "" "nsmnow"
if [ ${?} -ne 0 ]
then
return 1
fi
#
# NSM Administration
#
create_dir "/usr/share/nsmnow/templates/snort/rules"
if [ ${?} -ne 0 ]
then
return 1
fi
# copy (old) Snort rules to templates directory
print_all "Copying rules file(s) to templates" 3
copy_and_cache_files "${NSMNOW_PATH}/templates/rules" "*" "/usr/share/nsmnow/templates/snort/rules" "" "" "snort"
if [ ${?} -ne 0 ]
then
return 1
fi
# install NSM administration library file(s)
print_all "Copying library file(s)" 3
copy_and_cache_files "${NSMNOW_PATH}/templates/lib" "*" "${GENERAL_LIB_DIR}/nsmnow" "" "" "nsmnow"
if [ ${?} -ne 0 ]
then
return 1
fi
# install NSM administration binary file(s)
print_all "Copying binary file(s)" 3
copy_and_cache_files "${NSMNOW_PATH}/templates/sbin" "*" "${GENERAL_SBIN_DIR}" "" "" "nsmnow"
if [ ${?} -ne 0 ]
then
return 1
fi
# install NSM administration init file(s)
print_all "Copying init file(s)" 3
copy_and_cache_files "${NSMNOW_PATH}/templates/init" "nsm nsm-server nsm-sensor" "/etc/init.d" "" "755" "nsmnow"
if [ ${?} -ne 0 ]
then
return 1
fi
# install NSM administration configuration file
print_all "Creating configuration file" 3
create_dir "/etc/nsm"
if [ ${?} -ne 0 ]
then
return 1
fi
if [ ! -f "/etc/nsm/administration.conf" ]
then
echo -e "NSM_LIB_DIR=\"${GENERAL_LIB_DIR}/nsmnow\"" > /etc/nsm/administration.conf
echo -e "NSM_GENERAL_LIB_DIR=\"${GENERAL_LIB_DIR}\"" >> /etc/nsm/administration.conf
echo -e "NSM_GENERAL_BIN_DIR=\"${GENERAL_BIN_DIR}\"" >> /etc/nsm/administration.conf
echo -e "NSM_GENERAL_SBIN_DIR=\"${GENERAL_SBIN_DIR}\"" >> /etc/nsm/administration.conf
echo -e "NSM_GENERAL_ETC_DIR=\"${GENERAL_ETC_DIR}\"" >> /etc/nsm/administration.conf
echo -e "NSM_GENERAL_INIT_DIR=\"${GENERAL_INIT_DIR}\"" >> /etc/nsm/administration.conf
echo -e "NSM_GENERAL_CRON_DIR=\"${GENERAL_CRON_DIR}\"" >> /etc/nsm/administration.conf
echo -e "SNORT_LIB_DIR=\"${GENERAL_LIB_DIR}\"" >> /etc/nsm/administration.conf
if [ ${?} -ne 0 ]
then
return 1
fi
cache_file_add "/etc/nsm/administration.conf" "nsmnow"
fi
return 0
}
nsm_package_nsm_uninstall()
{
cache_group_remove "nsmnow"
}
nsm_package_nsm_upgrade()
{
print_all "nsm has no upgrade options enabled" 2
}