-
Notifications
You must be signed in to change notification settings - Fork 1
/
installer.sh
175 lines (150 loc) · 5.2 KB
/
installer.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/data/data/com.termux/files/usr/bin/bash
############################################
# ANSI variables
# ==========================================
############################################
# ANSI styles
NORMAL="\e[0m"
BOLD="\e[1m"
FAINT="\e[2m"
ITALIC="\e[3m"
UNDERLINE="\e[4m"
############################################
# ANSI Foregroud Colors
BLACK="\e[30m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
PURPLE="\e[35m"
CYAN="\e[36m"
LIGHT_GRAY="\e[37m"
############################################
# ANSI Background Colors
BG_BLACK="\e[40m"
BG_RED="\e[41m"
BG_GREEN="\e[42m"
BG_YELLOW="\e[43m"
BG_BLUE="\e[44m"
BG_PURPLE="\e[45m"
BG_CYAN="\e[46m"
BG_LIGHT_GRAY="\e[47m"
# ========= end of ANSI variables =========
###########################################
# Unicode variables
# =========================================
TICK="\u2713"
CROSS="\u274c"
# ======== end of Unicode variables =======
###########################################
# Global variables
# =========================================
# ======== end of Global variables ========
###########################################
# Functions
###########################################
###########################################
# prints banner on the screen
banner() {
echo -e "${CYAN}"
echo -e "██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗"
echo -e "██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗"
echo -e "██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝"
echo -e "██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗"
echo -e "██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║"
echo -e "╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝"
echo -e "${NORMAL}"
echo -e "================================================"
echo -e "Script by ${GREEN}dmdhrumilmistry${NORMAL}"
echo -e "================================================\n\n"
}
###########################################
# prints info message
print_info() {
local message=$1
if [ "$message" != "" ]; then
echo -e "${BOLD}${YELLOW}[*] ${message}${NORMAL}"
fi
}
###########################################
# prints error message
print_err() {
local message=$1
if [ "$message" != "" ]; then
echo -e "${BOLD}${RED}[${CROSS}] ${message}${NORMAL}"
fi
}
###########################################
# prints successs message
print_success() {
local message=$1
if [ "$message" != "" ]; then
echo -e "${BOLD}${GREEN}[${TICK}] ${message}${NORMAL}"
fi
}
###########################################
# updates and upgrades packages
update_and_upgrade() {
apt update -y && apt upgrade -y
if [ $status != 0 ]; then
print_err "Packages Upgrade failed! Exiting."
exit 1
else
print_success "Packages Upgraded successfully."
fi
}
###########################################
# to install requirements
install_reqs() {
local packages=("python" "git")
for package in "${packages[@]}"; do
print_info "Installing $package package."
apt install $package -y
local status=$?
if [ $status != 0 ]; then
print_err "$package installation failed! Exiting."
exit 1
else
print_success "$package installed successfully."
fi
done
}
###########################################
# starts main script
start() {
local repo_link="https://github.com/dmdhrumilmistry/TermuxScripts.git"
local folder_name="TermuxScripts"
# print banner
banner
# Upgrade packages
# print_info "Upgrading Packages"
# update_and_upgrade
# install requirements
print_info "Installing requirements"
install_reqs
# remove directory if already exists
rm -rf $folder_name
# install project
cd $HOME
git clone --depth=1 $repo_link
local status=$?
if [ $status != 0 ]; then
print_err "Clone failed! Exiting."
exit 1
else
print_success "Cloned successfully in ${HOME}"
fi
# add execution permission for python script
chmod +x ${HOME}/${folder_name}/termux-scripts.py
# install python requirements
python -m pip install -r ${HOME}/${folder_name}/requirements.txt
# print info
print_info "Run termux-script.py file using:"
print_info "python termux-script.py"
}
# ============ end of Functions ============
###########################################
# Script
###########################################
start
# ============= end of Script =============