@@ -10,8 +10,6 @@ cyan='\033[0;36m'
10
10
white=' \033[0;37m'
11
11
rest=' \033[0m'
12
12
13
- #! /bin/bash
14
-
15
13
if [ -d " $HOME /.termux" ] && [ -z " $( command -v jq) " ]; then
16
14
echo " Running update & upgrade ..."
17
15
pkg update -y
21
19
# Check and install necessary packages
22
20
install_packages () {
23
21
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
32
48
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} "
35
50
fi
36
51
}
52
+
37
53
install_packages
38
54
# Download and install Xray if not already installed
39
55
if ! [ -x " $PREFIX /bin/xray" ]; then
0 commit comments