forked from R-s0n/ars0n-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
75 lines (65 loc) · 2 KB
/
run.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
#!/bin/bash
cleanup() {
echo -e "\n\e[1mScript terminated. Cleaning up...\e[0m"
pkill -P $$
wait
sudo fuser -k "5000/tcp"
sleep 5
echo -e "\e[1mCleanup completed.\e[0m"
exit 0
}
user_prompt() {
read -r -p "Processes are running on ports 8000, 3000, or 5000. Do you want to stop them? (y/n): " response
case "$response" in
[yY])
for port in 8000 3000 5000; do
if fuser "$port/tcp" > /dev/null 2>&1; then
echo "Stopping process running on port $port..."
sudo fuser -k "$port/tcp"
sleep 5
fi
done
;;
*)
echo "Exiting the script without stopping processes."
cleanup
;;
esac
}
trap cleanup SIGTERM SIGINT
for port in 8000 3000 5000; do
if fuser "$port/tcp" > /dev/null 2>&1; then
user_prompt
break
fi
done
if [[ "$1" == "--arm" ]]; then
sudo systemctl enable mongodb 2>/dev/null
sudo systemctl start mongodb 2>/dev/null
if sudo systemctl is-active --quiet mongodb; then
echo "MongoDB is running. Continuing..."
else
echo "Error: MongoDB is not running! Please turn on your local MongoDB instance to use the Ars0n Framework. Exiting..."
exit 1
fi
else
sudo systemctl enable mongod 2>/dev/null
sudo systemctl start mongod 2>/dev/null
if sudo systemctl is-active --quiet mongod; then
echo "MongoDB is running. Continuing..."
else
echo "Error: MongoDB is not running! Please turn on your local MongoDB instance to use the Ars0n Framework. Exiting..."
exit 1
fi
fi
nohup node server/server.js > logs/server.log 2>&1 &
(
cd client || { echo "Error: 'client' directory not found."; exit 1; }
nohup npm run start > ../logs/client.log 2>&1 &
)
(
cd toolkit || { echo "Error: 'toolkit' directory not found."; exit 1; }
nohup python3 toolkit-service.py > ../logs/toolkit.log 2>&1 &
)
tail -f logs/toolkit.log &
wait