-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
90 lines (68 loc) · 2.18 KB
/
setup.sh
File metadata and controls
90 lines (68 loc) · 2.18 KB
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
#!/usr/bin/env bash
set -e # exit on error immediately
USER_NAME=$(logname 2>/dev/null) # Log the username who ran sudo
# OpenSearchAPI Setup Script - SudoHopeX
# Updated: 7 Feb 2026
# verify script is executed with sudo permissions
if [ "$EUID" -ne 0 ]; then
echo "[!] This script must be run with sudo."
exit 1
fi
# update system
echo "[+] Updating the System..."
if apt update > /dev/null 2>&1; then
echo "[✓] System Updated..."
else
echo "[!] System Update failed."
exit 1
fi
# installing dependencies if not found on system
install_if_missing() {
for pkg in "$@"; do
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
echo "$pkg Installing..."
apt-get install "$pkg" -y > /dev/null 2>&1
echo "$pkg Installation Complete"
else
echo "[✓] $pkg is already installed."
fi
done
}
# install system packages
echo ""
echo "[+] System Requirements Check..."
install_if_missing chromium python3 python3-pip python3-venv xvfb
# make folder within /opt dir
mkdir -p /opt/OpenSearchAPI
cd /opt/OpenSearchAPI
# clone the github repo
echo ""
echo "Cloning GitHub Repo 'OpenSearchAPI'"
git clone https://github.com/SudoHopeX/OpenSearchAPI.git /opt/OpenSearchAPI > /dev/null 2>&1
# make python venv
python -m venv /opt/OpenSearchAPI/its_venv
source /opt/OpenSearchAPI/its_venv/bin/activate
# install pip requirements
echo "[+] Installing pip Requirements..."
pip install requests beautifulsoup4 flask ddgs curl_cffi nodriver pyvirtualdisplay > /dev/null 2>&1
# create a simple launcher for starting OpenSearchAPI in bg
sudo tee /usr/local/bin/opensearchapi > /dev/null <<'EOF'
#!/usr/bin/env bash
# echo "SudoHopeX - OpenSearchAPI"
source /opt/OpenSearchAPI/its_venv/bin/activate
if [ "$1" == "--bg" ]; then
python /opt/OpenSearchAPI/app.py > /dev/null 2>&1 &
APP_ID=$!
echo "$APP_ID"
else
python /opt/OpenSearchAPI/app.py
APP_ID=$!
echo "OpenSearchAPI Started with PID: $APP_ID"
fi
deactivate
EOF
chmod +x /usr/local/bin/opensearchapi
# changing the ownership of /opt/OpenSearchAPI to the actual user who ran sudo
chown -R "$USER_NAME":"$USER_NAME" /opt/OpenSearchAPI/
# test the launcher
opensearchapi