-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·180 lines (147 loc) · 4.25 KB
/
install.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
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
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
#
#
# install.sh - script for installation
#
# lsi - A collection of scripts and programs that allow for the gathering
# and reporting of Linux/Unix systems information.
#
# Copyright (C) 2010, Rick Briganti
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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, see <http://www.gnu.org/licenses/>.
#
#
CWD=`dirname $0`
# check prerequisites for the client
$CWD/src/bin/verifyPreReq.sh
if [ "$?" -ne 0 ];then
exit 1
fi
install() {
echo -n "Enter the install location (default: /usr/local/lsi): "
read prefix
if [ -z $prefix ];then
prefix="/usr/local/lsi"
fi
echo -n "You have entered: $prefix, is this correct (Y/n): "
read confirm
if [ -z $confirm ];then
confirm="y"
fi
}
# launch install
echo
install
# loop until
while [ "`echo $confirm | tr [A-Z] [a-z]`" != "y" ];do
echo
echo "You must enter 'y' to complete the install. You entered: $confirm"
echo
install
done
# set collection server ip addresses
while [ "`echo $ipconfirm | tr [A-Z] [a-z]`" != "y" ]; do
echo
echo -n "Enter the Collection server IP Address (default: 127.0.0.1): "
read ipaddr
if [ -z $ipaddr ];then
ipaddr="127.0.0.1"
fi
echo -n "You have entered: $ipaddr, is this correct (Y/n): "
read ipconfirm
if [ -z $ipconfirm ];then
ipconfirm="y"
fi
done
# set port in /etc/services for xinetd
while [ "`echo $tcpconfirm | tr [A-Z] [a-z]`" != "y" ]; do
echo
echo -n "Enter the desired TCP Port number (default: 8730): "
read tcpport
if [ -z $tcpport ];then
tcpport="8730"
fi
PORT=`grep -v "^#" /etc/services | grep -P "\s+$tcpport\/tcp"`
if [ $? -eq 0 ];then
echo
echo "WARNING: $tcpport/tcp found in /etc/services!"
echo "WARNING: $PORT"
echo
echo -n "Are you sure you want to use $tcpport/tcp (Y/n): "
read tcpconfirm
else
echo -n "You have entered: $tcpport, is this correct (Y/n): "
read tcpconfirm
fi
if [ -z $tcpconfirm ];then
tcpconfirm="y"
fi
done
echo
echo "Setup will continue in 5 seconds, press CTRL+C to exit setup..."
sleep 5
echo
echo "Installing to $prefix ..."
echo
mkdir -p $prefix
cp -Rv $CWD/src/* $prefix
echo
echo "Updating default LSI configurations with the new install"
echo "location."
REPLACE=$(printf "%s\n" "$prefix" | sed 's/[][\.*^$/]/\\&/g')
sed -i -e "s/PREFIX/$REPLACE/g" $prefix/etc/stunnel/*.conf
sed -i -e "s/PREFIX/$REPLACE/g" $prefix/share/doc/xinetd-example
if [ -f /etc/xinetd.d/lsi ];then
echo
echo "Backing up existing /etc/xinetd.d/lsi"
echo
cp -v /etc/xinetd.d/lsi /etc/xinetd.d/lsi.$$.`date +%Y%m%d`
fi
echo
echo "Creating new /etc/xinetd.d/lsi"
echo
cp -v $prefix/share/doc/xinetd-example /etc/xinetd.d/lsi
echo
echo "Backing up existing /etc/services"
cp /etc/services /etc/services.$$.`date +%Y%m%d`
echo "Added the following to /etc/services"
echo
echo "lsi $tcpport/tcp # lsi service" | tee -a /etc/services
echo
# create hosts.allow entry for lsi
if [ -f /etc/hosts.allow ];then
echo "Backing up existing /etc/hosts.allow"
cp /etc/hosts.allow /etc/hosts.allow.$$.`date +%Y%m%d`
grep -q "^lsi:" /etc/hosts.allow
if [ $? -eq 0 ];then
sed -i -e 's/^lsi:.*//g' /etc/hosts.allow
fi
echo "Adding lsi to /etc/hosts.allow"
echo "lsi: $ipaddr" >> /etc/hosts.allow
fi
echo
# create hosts.deny entry for lsi
if [ -f /etc/hosts.deny ];then
echo "Backing up existing /etc/hosts.deny"
cp /etc/hosts.deny /etc/hosts.deny.$$.`date +%Y%m%d`
grep -q "^lsi:" /etc/hosts.deny
if [ $? -eq 0 ];then
sed -i -e 's/^lsi:.*//g' /etc/hosts.deny
fi
echo "Adding lsi to /etc/hosts.deny"
echo "lsi: ALL" >> /etc/hosts.deny
fi
echo
echo "Installation complete, please review installation output for"
echo "errors. Please start/restart xinetd for the changes to take effect."