Skip to content

Commit b458703

Browse files
committed
update install.sh
1 parent 45dec58 commit b458703

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

install.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ cyan='\033[0;36m'
1010
white='\033[0;37m'
1111
rest='\033[0m'
1212

13-
#!/bin/bash
14-
1513
if [ -d "$HOME/.termux" ] && [ -z "$(command -v jq)" ]; then
1614
echo "Running update & upgrade ..."
1715
pkg update -y
@@ -21,19 +19,37 @@ fi
2119
# Check and install necessary packages
2220
install_packages() {
2321
local packages=(wget curl unzip jq)
24-
if [ -n "$(command -v pkg)" ]; then
25-
pkg install "${packages[@]}" -y
26-
elif [ -n "$(command -v apt)" ]; then
27-
sudo apt install "${packages[@]}" -y
28-
elif [ -n "$(command -v yum)" ]; then
29-
sudo yum install "${packages[@]}" -y
30-
elif [ -n "$(command -v dnf)" ]; then
31-
sudo dnf install "${packages[@]}" -y
22+
local missing_packages=()
23+
24+
# Check for missing packages
25+
for pkg in "${packages[@]}"; do
26+
if ! command -v "$pkg" &> /dev/null; then
27+
missing_packages+=("$pkg")
28+
fi
29+
done
30+
31+
# If any package is missing, install missing packages
32+
if [ ${#missing_packages[@]} -gt 0 ]; then
33+
if [ -n "$(command -v pkg)" ]; then
34+
pkg install "${missing_packages[@]}" -y
35+
elif [ -n "$(command -v apt)" ]; then
36+
sudo apt update -y
37+
sudo apt install "${missing_packages[@]}" -y
38+
elif [ -n "$(command -v yum)" ]; then
39+
sudo yum update -y
40+
sudo yum install "${missing_packages[@]}" -y
41+
elif [ -n "$(command -v dnf)" ]; then
42+
sudo dnf update -y
43+
sudo dnf install "${missing_packages[@]}" -y
44+
else
45+
echo -e "${yellow}Unsupported package manager. Please install required packages manually.${rest}"
46+
exit 1
47+
fi
3248
else
33-
echo -e "${red}Unsupported package manager. Please install required packages manually.${rest}"
34-
exit 1
49+
echo -e "${green}All packages are already installed.${rest}"
3550
fi
3651
}
52+
3753
install_packages
3854
# Download and install Xray if not already installed
3955
if ! [ -x "$PREFIX/bin/xray" ]; then

0 commit comments

Comments
 (0)