-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
69 lines (44 loc) · 1.82 KB
/
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
#!/bin/sh -e
# Created by Marcin Ulikowski <[email protected]>
# This script downloads and extracts required libraries, and then builds complete add-on package file
PACKAGE_NAME="SA_dnstwist.tgz"
SPLUNK_SDK_URL="https://files.pythonhosted.org/packages/ee/4a/e92bc2d09cbaafcf54f1226bb1e87988ab2c657cd65c9a9a081e94760b81/splunk-sdk-1.7.4.tar.gz"
IDNA_URL="https://files.pythonhosted.org/packages/8b/e1/43beb3d38dba6cb420cefa297822eac205a277ab43e5ba5d5c46faf96438/idna-3.4.tar.gz"
DNSTWIST_URL="https://files.pythonhosted.org/packages/3f/df/9c62d9e40d374fd1311de3c761670771615101e0a0b31968b31289882db7/dnstwist-20240812.tar.gz"
ADDON_DIR="SA_dnstwist"
LIB="./$ADDON_DIR/lib"
if [ ! -d "$LIB" ]; then
echo "Error: '$LIB' does not exist!"
exit 1
fi
if [ -n "$(ls $LIB)" ]; then
echo "Error: '$LIB' should be empty!"
exit 1
fi
for i in wget tar gzip; do
T=$(which "$i" 2>/dev/null)
if [ "$T" = "" ]; then
echo "Error: '$i' not found, please install first."
exit 1
fi
done
echo "Downloading Splunk-SDK from the web ..."
wget -nv -O - -- "$SPLUNK_SDK_URL" | \
tar --wildcards --no-wildcards-match-slash --strip-components=1 -xzf - -C "$LIB" "*/splunklib/*"
echo "Downloading IDNA from the web ..."
wget -nv -O - -- "$IDNA_URL" | \
tar --wildcards --no-wildcards-match-slash --strip-components=1 -xzf - -C "$LIB" "*/idna/*"
echo "Downloading dnstwist from the web ..."
wget -nv -O - -- "$DNSTWIST_URL" | \
tar --wildcards --no-wildcards-match-slash --strip-components=1 -xzf - -C "$LIB" "*/dnstwist.py"
echo "Setting 0644 permissions ..."
find "$LIB" -type f -name "*.py" -exec chmod 644 {} \;
echo "Building package ..."
COPYFILE_DISABLE=1 tar --format ustar \
--exclude="$0" \
--exclude="$PACKAGE_NAME" \
--exclude=".gitignore" \
-cvzf "$PACKAGE_NAME" "$ADDON_DIR"
echo "Done!"
echo "Package file: $PACKAGE_NAME"
exit 0