-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.bash
90 lines (81 loc) · 2.67 KB
/
installer.bash
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
#!/bin/bash
# Define an array of programs to install
PROGRAMS=(
"python3"
"unzip"
"grep" # Useful for most tasks
"ngrep" # Useful for most tasks
"nmap"
"snort" # May or may not be useful for Task 4P
"wireshark" # Task 1P, 1C, C1 & D2
"tshark" # Task 3P & 5.1P
"tcpdump" # Task C1
"aircrack-ng" # Task D2
# The next set of programs are installed with NFdump but will need
# to be installed by the user if the repository wasn't cloned.
# "bison" # Task 2.1 & D1
# "flex" # Task 2.1 & D1
# "rrdtool" # Task 2.1 & D1
# "librrd-dev" # Task 2.1 & D1
# "argus-client" # Task 2.1 & D1
)
# Update the package list
echo "Updating package list..."
sudo apt-get update
# Upgrade installed packages to their latest versions
echo "Upgrading installed packages..."
sudo apt-get upgrade -y
# Install each program listed in the PROGRAMS array
echo "Installing programs..."
for PROGRAM in "${PROGRAMS[@]}"; do
if ! dpkg -s $PROGRAM >/dev/null 2>&1; then
echo "Installing $PROGRAM..."
sudo apt-get install -y $PROGRAM
else
echo "$PROGRAM is already installed."
fi
done
# Install older nfdump version (Using clang-10 in our array would work if we wanted up to date)
wget http://sourceforge.net/projects/nfdump/files/nsel/nfdump-1.5.8-NSEL/nfdump-1.5.8-NSEL.tar.gz/download
tar xzf download
# Copy downloaded files (assuming they are in the current directory)
if [ -d "SIT327 Task Resources" ]; then
echo "Task Resources present preparing for first task"
echo "Unzipping Task Resources ..."
cd "SIT327 Task Resources/"
for file in *.zip; do
filename="${file%.*}"
makdir -p "$filename"
echo y | unzip -q "$file" -d "$filename"
done
cd ..
cp -f "SIT327 Task Resources/2.1P-resources/nf_common.c" "nfdump-1.5.8-NSEL/"
cp -f "SIT327 Task Resources/2.1P-resources/nf_common.h" "nfdump-1.5.8-NSEL/"
cp "SIT327 Task Resources/2.1P-resources/argus-collector.ra" "nfdump-1.5.8-NSEL/"
echo "\nReady to complete task 2.1P"
sudo apt-get install bison flex rrdtool librrd-dev argus-client
cd nfdump-1.5.8-NSEL/
./configure --enable-nfprofile
make
make install
cd ..
echo "\n Great success!"
else
echo "Task Resources not present you will need to configure NFdump!"
fi
# Clean up unnecessary packages and files
echo "Cleaning up..."
sudo apt-get autoremove -y
sudo apt-get clean
echo "All programs installed successfully!"
# Optional: Verification of installations
echo "Verifying installations..."
for PROGRAM in "${PROGRAMS[@]}"; do
if which $PROGRAM >/dev/null 2>&1; then
echo "$PROGRAM is installed and working."
else
echo "Error: $PROGRAM is not installed correctly."
fi
done
echo "Good luck this Trimester!"
echo "Script execution completed."