-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsys-install
122 lines (110 loc) · 3.78 KB
/
sys-install
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
116
117
118
119
120
121
122
#!/data/data/com.termux/files/usr/bin/bash
# Author: Abdul Jaber(Aj-Seven)
# Github: @Aj-Seven
# Reddit: @A_J07
red='\033[1;91m'
green='\033[1;92m'
off='\033[0;0m'
cyan='\033[1;96m'
yellow='\033[1;33m'
white='\033[1;97m'
clear
echo -e "$yellow Name:$off$white sysinfo installer$off"
echo -e "$yellow Version:$off$white V2.0$off"
echo -e "$white Installing Required Dependencies. Please wait... :) $off"
echo -e "$cyan Installation Depends on internet speed$off"
# Function to install package and show message
install_package() {
local package_name="$1"
if ! command -v "$package_name" >/dev/null 2>&1; then
echo -e "$cyan (Installing $package_name...) $off"
if pkg install -y "$package_name" >/dev/null 2>&1; then
echo -e "$green Installed $package_name successfully $off"
else
echo -e "$red Failed to install $package_name $off"
exit 1
fi
else
echo -e "$green $package_name is already installed $off"
fi
}
# Function to check if tput exists under ncurses-utils package
check_without_version() {
if [[ (-f $PREFIX/bin/termux-battery-status) && (-f $PREFIX/bin/tput) ]]; then
echo -e "$green termux-api is already installed$off"
echo -e "$green tput is already installed$off"
else
echo -e "$yellow Installing termux-api...$off"
if pkg install -y termux-api >/dev/null 2>&1; then
echo -e "$green Installed termux-api successfully$off"
else
echo -e "$red Failed to install termux-api$off"
exit 1
fi
echo -e "$yellow Installing tput...$off"
if pkg install -y ncurses-utils >/dev/null 2>&1; then
echo -e "$green Installed tput successfully$off"
else
echo -e "$red Failed to install tput$off"
exit 1
fi
fi
}
install_script() {
REPO_URL="https://github.com/Aj-Seven/Android-Sysinfo"
REPO_DIR="$PREFIX/share/Android-Sysinfo"
SCRIPT_NAME="sysinfo"
BIN_DIR="$PREFIX/bin"
SCRIPT_PATH="$BIN_DIR/$SCRIPT_NAME"
echo -e "$red Deleting files from previous installation... $off"
rm -rf $SCRIPT_PATH $REPO_DIR >/dev/null 2>&1;
# Clone the repository directory
echo -e "$cyan Cloning repository directory... $off"
if git clone "$REPO_URL" "$REPO_DIR" >/dev/null 2>&1; then
echo -e "$green Repository directory cloned Successfully... $off"
# Check if the script file exists in the repository directory
if [ -f "$REPO_DIR/$SCRIPT_NAME" ]; then
# Create a symbolic link to the script in the bin directory
ln -s "$REPO_DIR/$SCRIPT_NAME" "$SCRIPT_PATH"
if [ -L "$SCRIPT_PATH" ]; then
echo -e "$green Script linked and Installed Successfully. Run it by sysinfo $off"
else
echo -e "$red Failed to link script $off"
exit 1
fi
else
echo -e "$red Script not Installed :( $off"
exit 1
fi
else
echo -e "$red Failed to clone repository directory $off"
exit 1
fi
}
install_pkg() {
echo -e "$yellow Performing package update...$off"
if pkg update -y >/dev/null 2>&1; then
echo -e "$green Package update completed successfully$off"
else
echo -e "$red Failed to update packages$off"
exit 1
fi
check_without_version
install_package curl
install_package git
install_package duf
install_package figlet
install_package bc
install_package jq
install_package nmap
install_package speedtest-go
}
# Set the default PREFIX if not provided
if [ -z "$PREFIX" ]; then
PREFIX="/data/data/com.termux/files/usr/"
fi
# Install packages
if ! install_pkg; then
echo -e "$red Installation of packages failed. Exiting...$off"
exit 1
fi