/
make_deb_package.sh
214 lines (183 loc) · 6.03 KB
/
make_deb_package.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
# Pandora FMS- http://pandorafms.com
# ==================================================
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
# Please see http:#pandorafms.org for full contribution list
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; version 2
# 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.
pandora_version="7.0NG.765-221027"
package_cpan=0
package_pandora=1
for param in $@
do
if [ $param = "-h" -o $param = "--help" ]
then
echo "For only make packages of cpan type +cpan"
echo "For not make packages of cpan type -cpan"
exit 0
fi
if [ $param = "+cpan" ]
then
package_pandora=0
fi
if [ $param = "-cpan" ]
then
package_cpan=0
fi
done
echo "This script to make deb must run as root (because the dh-make-perl need this). Then test if you are root."
if [ `id -u` != 0 ]
then
echo "You aren't root."
exit 1
fi
if [ $package_cpan -eq 1 ]
then
echo "Test if you has the tools for to make the packages."
whereis dh-make-perl | cut -d":" -f2 | grep dh-make-perl > /dev/null
if [ $? = 1 ]
then
echo "No found \"dh-make-perl\" aplication, please install."
exit 1
else
echo "Found \"dh-make-perl\"."
fi
fi
cd ..
echo "Make a \"temp_package\" temp dir for job."
mkdir temp_package
if [ $package_pandora -eq 1 ]
then
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
if [ $? = 1 ]
then
if [ "$DPKG_DEB" == "" ]; then
echo "No found \"dpkg-deb\" aplication, please install."
exit 1
fi
echo ">> Using dockerized version of dpkg-deb: "
echo " $DPKG_DEB"
# Use dockerized app.
USE_DOCKER_APP=1
else
echo "Found \"dpkg-debs\"."
fi
mkdir -p temp_package/usr/bin/
mkdir -p temp_package/usr/sbin/
mkdir -p temp_package/etc/init.d/
mkdir -p temp_package/lib/systemd/system/
mkdir -p temp_package/etc/pandora/
mkdir -p temp_package/etc/tentacle/
mkdir -p temp_package/var/spool/pandora/data_in
chmod 770 temp_package/var/spool/pandora/data_in
mkdir -p temp_package/var/spool/pandora/data_in/conf
mkdir -p temp_package/var/spool/pandora/data_in/md5
chmod 770 temp_package/var/spool/pandora/data_in/md5
mkdir -p temp_package/var/spool/pandora/data_in/collections
chmod 770 temp_package/var/spool/pandora/data_in/collections
mkdir -p temp_package/var/spool/pandora/data_in/netflow
chmod 770 temp_package/var/spool/pandora/data_in/netflow
mkdir -p temp_package/var/spool/pandora/data_in/trans
chmod 770 temp_package/var/spool/pandora/data_in/trans
mkdir -p temp_package/var/spool/pandora/data_in/commands
chmod 770 temp_package/var/spool/pandora/data_in/commands
mkdir -p temp_package/var/log/pandora/
chmod 754 temp_package/var/log/pandora/
mkdir -p temp_package/usr/share/pandora_server/conf/
mkdir -p temp_package/usr/share/tentacle_server/conf/
mkdir -p temp_package/usr/lib/perl5/
mkdir -p temp_package/usr/share/man/man1/
mkdir -p temp_package/etc/logrotate.d/
cp -aRf bin/pandora_server temp_package/usr/bin/
cp -aRf bin/pandora_exec temp_package/usr/bin/pandora_exec.server
cp -aRf bin/tentacle_server temp_package/usr/bin/
cp -aRf conf/pandora_* temp_package/usr/share/pandora_server/conf/
cp -aRf conf/tentacle_* temp_package/usr/share/tentacle_server/conf/
cp -aRf util temp_package/usr/share/pandora_server/
cp -aRf util/pandora_ha.pl temp_package/usr/bin/pandora_ha
cp -aRf lib/* temp_package/usr/lib/perl5/
cp -aRf AUTHORS COPYING README temp_package/usr/share/pandora_server/
cp -aRf util/pandora_server temp_package/etc/init.d/
cp -aRf util/tentacle_serverd temp_package/etc/init.d/
cp -aRf util/pandora_server.service temp_package/lib/systemd/system/
cp -aRf util/tentacle_serverd.service temp_package/lib/systemd/system/
cp -aRf man/man1/* temp_package/usr/share/man/man1/
cp -aRf util/pandora_server_logrotate temp_package/etc/logrotate.d/pandora_server
rm -f temp_package/usr/share/pandora_server/util/PandoraFMS
rm -f temp_package/usr/share/pandora_server/bin/PandoraFMS
rm -f temp_package/usr/share/pandora_server/util/recon_scripts/PandoraFMS
cp -R DEBIAN temp_package/
chmod 755 -R temp_package/DEBIAN
echo "Remove the SVN files and other temp files."
for item in `find temp_package`
do
echo -n "."
echo $item | grep "svn" > /dev/null
#last command success
if [ $? -eq 0 ]
then
rm -rf $item
fi
echo $item | grep "make_deb_package.sh" > /dev/null
#last command success
if [ $? -eq 0 ]
then
rm -rf $item
fi
done
echo "END"
echo " "
pwd
echo " "
echo "Calcule md5sum for md5sums file control of package."
for item in `find temp_package`
do
echo -n "."
if [ ! -d $item ]
then
echo $item | grep "DEBIAN" > /dev/null
#last command success
if [ $? -eq 1 ]
then
md5=`md5sum $item | cut -d" " -f1`
#delete "temp_package" in the path
final_path=${item#temp_package}
echo $md5" "$final_path >> temp_package/DEBIAN/md5sums
fi
fi
done
echo "END"
echo "Make the package \"Pandorafms server\"."
if [ "$USE_DOCKER_APP" == "1" ]; then
eval $DPKG_DEB --build temp_package
else
dpkg-deb --build temp_package
fi
mv temp_package.deb pandorafms.server_$pandora_version.deb
echo "generated: pandorafms.server_$pandora_version.deb"
pwd
ls -lah pandorafms.server_$pandora_version.deb
chmod 777 pandorafms.server_$pandora_version.deb
fi
if [ $package_cpan -eq 1 ]
then
echo "Make the package \"libnet-traceroute-pureperl-perl\"."
cd temp_package
dh-make-perl --build --cpan Net::Traceroute::PurePerl
chmod 777 libnet-traceroute-pureperl-perl*.deb
mv libnet-traceroute-pureperl-perl*.deb ..
cd ..
echo "Make the package \"libnet-traceroute-perl\"."
cd temp_package
dh-make-perl --build --cpan Net::Traceroute
chmod 777 libnet-traceroute-perl*.deb
mv libnet-traceroute-perl*.deb ..
cd ..
fi
echo "Delete the \"temp_package\" temp dir for job."
rm -rf temp_package