-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
116 lines (100 loc) · 3.45 KB
/
setup.sh
File metadata and controls
116 lines (100 loc) · 3.45 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
set -e
# 🎨 Banner
banner() {
echo -e "\e[1;36m"
echo "╔══════════════════════════════════════╗"
echo "║ 🔐 By Sayyad — Python Defender Pro ║"
echo "╚══════════════════════════════════════╝"
echo -e "\e[0m"
}
banner
# 🧠 دوال مساعدة
command_exists() {
command -v "$1" >/dev/null 2>&1
}
package_installed() {
pip show "$1" >/dev/null 2>&1
}
fix_pip() {
echo "🚑 Running pip fix from GitHub..."
curl -sL https://raw.githubusercontent.com/Sayyad-N/fix-pip/main/fix_pip_problems.sh -o fix-pip.sh
if grep -q "404: Not Found" fix-pip.sh || ! grep -q "#!/bin/bash" fix-pip.sh; then
echo -e "\e[1;31m❌ Failed to download or verify fix-pip.sh. Check the GitHub link!\e[0m"
rm -f fix-pip.sh
exit 1
fi
chmod +x fix-pip.sh
echo "5" | ./fix-pip.sh
rm -f fix-pip.sh
}
# ✅ التحقق من Python و pip
echo "🔍 Checking for Python3..."
if ! command_exists python3; then
echo -e "\e[1;31m❌ Python3 not found. Please install it manually.\e[0m"
exit 1
fi
echo "🔍 Checking for pip..."
if ! command_exists pip; then
echo "⚠️ pip not found. Installing..."
curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py || python get-pip.py
rm -f get-pip.py
fi
echo -e "\e[1;32m✅ Python and pip are ready.\e[0m"
# 📦 الحزم المطلوبة
PY_PACKAGES=("python-nmap" "google-genai" "colorama")
ALL_INSTALLED=true
echo -e "\n⬇️ Checking Python packages..."
for pkg in "${PY_PACKAGES[@]}"; do
if package_installed "$pkg"; then
echo -e "✅ $pkg is already installed."
else
echo -e "📦 Installing $pkg..."
if ! pip install "$pkg"; then
echo -e "\e[1;33m⚠️ Failed to install $pkg. Trying pip fix...\e[0m"
fix_pip
if ! pip install "$pkg"; then
echo -e "\n❓ \e[1;31mFailed to install $pkg even after pip fix.\e[0m"
read -p "Do you want to continue without it? (y/n): " choice
if [[ "$choice" =~ ^[Nn]$ ]]; then
echo -e "\n🛑 Aborting as requested by user."
exit 1
else
echo -e "⚠️ Continuing without $pkg."
fi
fi
fi
ALL_INSTALLED=false
fi
done
# 🛠 تثبيت nmap
echo -e "\n🔍 Checking for nmap..."
if command_exists nmap; then
echo -e "✅ nmap is already installed."
else
echo -e "📦 Installing nmap..."
if command_exists apt; then
sudo apt update && sudo apt install -y nmap
elif command_exists dnf; then
sudo dnf install -y nmap
elif command_exists yum; then
sudo yum install -y nmap
elif command_exists pacman; then
sudo pacman -Sy --noconfirm nmap
elif command_exists zypper; then
sudo zypper install -y nmap
elif command_exists apk; then
sudo apk add nmap
else
echo -e "\e[1;31m❌ Unknown package manager. Please install nmap manually.\e[0m"
exit 1
fi
ALL_INSTALLED=false
fi
# ✅ تقرير نهائي
if $ALL_INSTALLED; then
echo -e "\n🎉 \e[1;32mEverything is already installed. You're good to go, باشا!\e[0m"
else
echo -e "\n✅ \e[1;32mSetup completed with some installations or fixes. All set!\e[0m"
fi