-
Notifications
You must be signed in to change notification settings - Fork 7
/
run.sh
62 lines (51 loc) · 1.82 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
#!/bin/bash
if ! command -v python3 &> /dev/null; then
echo "Python3 is not installed."
sudo apt update
sudo apt install python3 -y
fi
if ! command -v pip &> /dev/null; then
echo "pip is not installed."
sudo apt install python3-pip -y || {
echo "Installing pip via alternative method..."
wget -qO- https://bootstrap.pypa.io/get-pip.py | sudo python3 -
}
fi
# Function to check if a Python library is installed
check_library() {
python3 -c "import $1" &> /dev/null
}
# Function to install library using apt if pip install fails
install_library_apt() {
local package_name="python3-$1"
sudo apt install "$package_name" -y
}
# Function to upgrade library using pip if upgrade fails
upgrade_library_pip() {
sudo pip install --upgrade "$1"
}
required_libraries=("paramiko==3.3.1" "requests==2.31.0")
for lib in "${required_libraries[@]}"; do
# Split the string to get the library name for checking
lib_name=$(echo "$lib" | cut -d '=' -f 1)
if ! check_library "$lib_name"; then
install_library_apt "$lib_name" || sudo pip install "$lib"
else
echo "$lib is already installed."
fi
done
# Command to upgrade requests and urllib3
if ! upgrade_library_pip "requests"; then
echo "Upgrade of requests via pip failed, attempting alternative method..."
install_library_apt "requests" || sudo pip install --upgrade "requests"
fi
if ! upgrade_library_pip "urllib3"; then
echo "Upgrade of urllib3 via pip failed, attempting alternative method..."
install_library_apt "urllib3" || sudo pip install --upgrade "urllib3"
fi
# Saving Script into > curlscript.py
curl -sSL https://raw.githubusercontent.com/ItsAML/MarzbanEZNode/main/curlscript.py > curlscript.py
# Running previously saved script
python3 curlscript.py
# (OPTIONAL) removing script
rm curlscript.py