-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·89 lines (76 loc) · 2.55 KB
/
release.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
#!/bin/sh -ex
case $(uname) in
Darwin|Linux)
sudo=sudo
zip=zip
;;
*_NT-*)
exe=.exe
zip=/c/msys64/usr/bin/zip
;;
*)
echo "unknown OS: $(uname)" >&2
exit 1
;;
esac
#
# Install Zeek packages. We don't use zkg because it didn't work
# out-of-the-box in recent attempts and our package installation
# requirements are little more than copying scripts. We already had
# the approach below working in our prior Windows port so we'll
# stick with it for now.
#
zkg_meta() {
section=${1:?'section required'}
option=${2:?'option required'}
python3 <<EOF
import configparser
c = configparser.ConfigParser()
c.read('zkg.meta')
print(c.get('$section', '$option', fallback=''))
EOF
}
install_zeek_package() {
github_repo=${1:?'github_repo required'}
git_ref=${2:?'git_ref required'}
package=${github_repo#*/}
mkdir $package
(
export PATH=/usr/local/zeek/bin:$PATH
cd $package
curl -sL https://github.com/$github_repo/tarball/$git_ref |
tar -xzf - --strip-components 1
script_dir=$(zkg_meta package script_dir)
$sudo cp -r "$script_dir" /usr/local/zeek/share/zeek/site/$package/
build_command=$(zkg_meta package build_command)
if [ "$build_command" ]; then
echo "building plugins not currently supported"
exit 1
fi
test_command=$(zkg_meta package test_command)
if [ "$test_command" ]; then
# Btest fails without explanation on the GitHub Actions
# Windows runners, so skip tests there.
if [ "$GITHUB_ACTIONS" != true -o "$OS" != Windows_NT ]; then
sh -c "$test_command"
fi
fi
echo "@load $package" | $sudo tee -a /usr/local/zeek/share/zeek/site/local.zeek
)
rm -r $package
}
$sudo pip3 install btest wheel
install_zeek_package brimdata/geoip-conn c9dd7f0f8d40573189b2ed2bae9fad478743cfdf
install_zeek_package salesforce/hassh 76a47abe9382109ce9ba530e7f1d7014a4a95209
install_zeek_package salesforce/ja3 421dd4f3616b533e6971bb700289c6bb8355e707
echo "@load policy/protocols/conn/community-id-logging" | $sudo tee -a /usr/local/zeek/share/zeek/site/local.zeek
#
# Create zip file.
#
mkdir -p zeek/bin zeek/lib/zeek zeek/share/zeek
cp zeekrunner$exe zeek/
cp /usr/local/zeek/bin/zeek$exe zeek/bin/
for d in base policy site builtin-plugins; do
cp -R /usr/local/zeek/share/zeek/$d zeek/share/zeek/
done
$zip -r zeek-$(git describe --always --tags).$(go env GOOS)-$(go env GOARCH).zip zeek