-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·95 lines (80 loc) · 2.66 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
#!/bin/bash
set -e
ECEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OUTPUT_PREFIX="ECEL INSTALLER:"
OUTPUT_ERROR_PREFIX="$OUTPUT_PREFIX ERROR:"
PYTHON_EXEC="python3"
### Helper functions
#
prompt_accepted_Yn() {
read -r -p "$1 [Y/n] " yn
case $yn in
[nN]*) return 1 ;;
*) return 0 ;;
esac
}
# Updates
#echo "Running apt-get update"
#apt-get -y update
#echo "Running apt-get upgrade"
#apt-get upgrade
### Check if running as root
#
if [ "$EUID" -ne 0 ]; then
echo "$OUTPUT_ERROR_PREFIX Please run this installation as root"
exit 1
fi
### Install dependencies
#
REQUIRED_PROGRAMS="openjdk-8-jdk zlib1g-dev libpng-dev libxtst-dev libgcc-9-dev python3-pip python3-xlib tcpdump python3-psutil" #python3-dpkt
REQUIRED_PYTHON_PACKAGES="schedule autopy netifaces service Image Pyro4 Pillow python-xlib configobj psutil pmw jinja2"
REQUIRED_PLUGINS="tshark auditd"
for plugin in $REQUIRED_PLUGINS; do
plugin_prompt="$plugin is not installed. Install it now (ECEL will still run, but the $plugin plugin(s) won't)?"
if ! command -v $plugin >/dev/null 2>&1 && prompt_accepted_Yn "$plugin_prompt"; then
REQUIRED_PROGRAMS="$REQUIRED_PROGRAMS $plugin"
fi
done
echo "$OUTPUT_PREFIX Installing dependecies"
if [ -x "/usr/bin/apt-get" ]; then
apt-get -y install $REQUIRED_PROGRAMS
elif [ -x "/usr/bin/yum" ]; then
yum install -y $REQUIRED_PROGRAMS
else
echo "$OUTPUT_ERROR_PREFIX Distribution not supported"
exit 1
fi
echo "$OUTPUT_PREFIX Installing python dependencies"
$PYTHON_EXEC -m pip install pip --upgrade
$PYTHON_EXEC -m pip install $REQUIRED_PYTHON_PACKAGES
### Create plugin configs
#
for plugin in "$ECEL_DIR"/plugins/collectors/*; do
#python3 creates temporary directories; this is in case they exist from a previous install
if [[ "$plugin" == *"__pycache__" ]]; then
continue
fi
if [ -d "$plugin" ]; then
if [ ! -f "$plugin"/config.json ]; then
scp "$plugin"/config.json.template "$plugin"/config.json
fi
if [ ! -f "$plugin"/config_schema.json ]; then
scp "$plugin"/config_schema.json.template "$plugin"/config_schema.json
fi
fi
done
### Compile parsers
#
echo "$OUTPUT_PREFIX Compiling parsers" #TODO: Compile new plugins
for plugin in "$ECEL_DIR"/plugins/parsers/*; do
if [ -d "$plugin" ] && ls "$plugin"/*.java > /dev/null 2>&1; then
javac "$plugin"/*.java
fi
done
javac -cp $ECEL_DIR/plugins/parsers/nmap/java_classes/*.java
### Set file permissions
#
echo "$OUTPUT_PREFIX Setting file permissions"
find ./ -name "*.sh" -exec chmod +x {} \;
chmod +x "$ECEL_DIR"/eceld_service
echo "$OUTPUT_PREFIX Installation Complete"