forked from darkwarrior3/termuxstyling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
327 lines (326 loc) · 8.07 KB
/
setup.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/data/data/com.termux/files/usr/bin/bash
clear
#get current dir
pdir=$(pwd)
#installing necessary packages
apt install figlet toilet -y > /dev/null 2>&1
pkg install ncurses-utils -y > /dev/null 2>&1
# Setting up commands
getCPos() (
local opt=$*
exec < /dev/tty
oldstty=$(stty -g)
stty raw -echo min 0
# on my system, the following line can be replaced by the line below it
echo -en "\033[6n" > /dev/tty
# tput u7 > /dev/tty # when TERM=xterm (and relatives)
IFS=';' read -r -d R -a pos
stty $oldstty
# change from one-based to zero based so they work with: tput cup $row $col
row=$((${pos[0]:2} - 1)) # strip off the esc-[
col=$((${pos[1]} - 1))
if [[ $opt =~ .*-row.* ]]
then
printf $row
else
printf $col
fi
)
spinner() (
PID=$!
stty -echo
local opt=$*
tput civis
cstat(){
local optstat="$(if [[ ! $opt =~ .*$1.* ]]
then
echo 0
else
echo 1
fi)"
#echo $opt
echo $optstat
}
#echo $(cstat -s)
if [ "$(cstat -s)" -eq 1 ]
then
printf '\n'
# While process is running...
while kill -0 $PID 2> /dev/null;
do
printf '\u2588\e[1B\e[1D\u2588\e[1A'
sleep 0.3
done
elif [ "$(cstat -p)" -eq 1 ]
then
while kill -0 $PID 2> /dev/null;
do
printf '\u2588\e[1B\e[1D\u2588\e[1A'
sleep 0.3
done
elif [ "$(cstat -t)" -eq 1 ]
then
until [ $(getCPos) -eq $(($(tput cols))) ]
do
#echo $(getCPos) >> log.txt
#getCPos
#tput cols
if [ ! $(getCPos) -eq $(($(tput cols)-1)) ]
then
printf '\u2588\e[1B\e[1D\u2588\e[1A'
printf '\u2588\e[1B\e[1D\u2588\e[1A'
else
#echo 1
#echo hi
local row=$(($(getCPos -row)+1))
local plen=$(tput cols)
printf '\u2588'
tput cup "$row" "$plen"
printf '\u2588'
break
fi
done
printf "\n\n\nDone!\n"
fi
#echo hh
tput cnorm
stty echo
)
#Updating secondary packages
echo Updating Packages....
pip install mdv > /dev/null 2>&1 & spinner -s
apt-get update > /dev/null 2>&1 & spinner -p
apt-get upgrade -y > /dev/null 2>&1 & spinner -p
apt-get autoremove > /dev/null 2>&1 & spinner -p
apt-get autoclean > /dev/null 2>&1 & spinner -p
apt-get install git -y > /dev/null 2>&1 & spinner -p && spinner -t
clear
#Script starts
#cd $HOME
#cd termuxstyling
echo Script made by:- Dark Warrior
#Uninstall
if [ -e ".user.cfg" ]
then
uname=$(sed '1q;d' .user.cfg)
istate=$(sed '2q;d' .user.cfg)
if [ "$istate" -eq "1" ]
then
printf "Uninstall? [Y/N]: "
read ink1
case $ink1 in
[yY][eE][sS]|[yY])
rm .user.cfg;
echo $uname > .user.cfg
echo 0 >> .user.cfg
cd
cd /$HOME
cd ..
cd usr/etc
echo "command_not_found_handle() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
}
PS1='\$ '" > bash.bashrc & echo "" & spinner -t && clear
echo "Welcome to Termux!
Wiki: https://wiki.termux.com
Community forum: https://termux.com/community
IRC channel: #termux on freenode
Gitter chat: https://gitter.im/termux/termux
Mailing list: [email protected]
Search packages: pkg search <query>
Install a package: pkg install <package>
Upgrade packages: pkg upgrade
Learn more: pkg help" > motd
cd
cd /$HOME
figlet FemurTech
echo Now Your Termux is back to Original
echo "Uninstalled Succesfully"
exit 0
;;
*)
;;
esac
fi
fi
#Assigns Username
if [ ! -e ".user.cfg" ]
then
printf "Type your username: "
read uname
echo "This is your username: $uname"
echo "$uname" > .user.cfg
echo "1" >> .user.cfg
clear
#Rename Username
else
printf "Would You Like to Change Your Username[Y/N]: "
read ink
case "$ink" in
[yY][eE][sS]|[yY])
rm .user.cfg;
clear
bash setup.sh;
;;
*)
clear
echo "Welcome back $uname"
;;
esac
fi
#installing script
echo "Installing..."
mkdir -p $PREFIX/var/lib/postgresql > /dev/null 2>&1 & spinner -s
if [ -e "/data/data/com.termux/files/usr/etc/motd" ];then rm ~/../usr/etc/motd;fi & spinner -p
sleep 0.1 & spinner -p && spinner -t
#Set default username if found null
if [ -z "$uname" ]
then
uname="FemurTech"
fi
#Sets bash.bashrc aka startup
echo "command_not_found_handle() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found "'$1'"
}
shell() {
bash \$1.sh 2>/dev/null
if [ \$? -ne 0 ]
then
bash \$1.bash 2>/dev/null
if [ \$? -ne 0 ]
then
printf '\e[0;31mNo shell script found\n'
fi
fi
}
shellx() {
bash \$1*.sh 2>/dev/null
if [ \$? -ne 0 ]
then
bash \$1*.bash 2>/dev/null
if [ \$? -ne 0 ]
then
printf '\e[0;31mNo shell script found\n'
fi
fi
}
cds() {
if [[ \$* == *\"-i\"* ]]
then
var=\"\$*\"
sub=\"\"
qry=\$( echo \$var | sed 's/-i//g' )
qry=\$( echo \$qry | sed 's/ //g' )
echo finding \\\"\$qry\\\"
cd \"\$( find \"\$(pwd)/\" -maxdepth 3 -not \\( -path \"/sdcard/Android/*\" -prune \\) -type d -iname \"\$qry\" -print -quit )\"
else
echo finding \$1
cd \"\$( find \"\$(pwd)/\" -maxdepth 3 -not \\( -path \"/sdcard/Android/*\" -prune \\) -type d -name \"\$1\" -print -quit )\"
fi
}
cdp() {
if [[ \$* == *\"-i\"* ]]
then
var=\"\$*\"
sub=\"\"
qry=\$( echo \$var | sed 's/-i//g' )
qry=\$( echo \$qry | sed 's/ //g' )
echo finding \\\"\$qry\\\"
cd \"\$( find \"\$(pwd)/\" -maxdepth 3 -not \\( -path \"/sdcard/Android/*\" -prune \\) -type d -iname \"\$qry\"* -print -quit )\"
else
echo finding \$1
cd \"\$( find \"\$(pwd)/\" -maxdepth 3 -not \\( -path \"/sdcard/Android/*\" -prune \\) -type d -name \"\$1\"* -print -quit )\"
fi
}
updatedw() {
ppath=\${pwd};
cd \$HOME
if [ -d \"\$HOME/termuxstyling\" ]
then
cd termuxstyling
git fetch >/dev/null
var=\$(git status | grep 'Your branch')
# echo \$var
if [[ \$var == *\"up to date\"* ]];
then
clear && echo \"Already running the latest version!!\" && echo ------------------------------------- && figlet \$(sed '1q;d' 'ver.cfg') && figlet FemurTech
else
git pull
bash setup.sh;
clear && echo \"Update Success\" && echo -------------- && figlet Success && figlet \$(sed '1q;d' 'ver.cfg') && figlet FemurTech && echo Restart to apply changes
fi
else
git clone https://github.com/darkwarrior3/termuxstyling.git
cd termuxstyling
prm sh
clear
bash
bash setup.sh
wait
echo \"Update Success\" && echo -------------- && figlet Success && figlet \$(sed '1q;d' '/data/data/com.termux/files/home/termuxstyling/ver.cfg') && figlet FemurTech && echo Restart to apply changes
fi
cd \$ppath
}
prm() { chmod +x *.\$1; }
txt() { cat \$1.*; }
figlet $uname
PS1='\033[1;91mroot@termux[\033[1;93m\W\033[1;91m]:
# \033[1;92m'
if [ -d \"\$HOME/termuxstyling\" ]
then
if grep -q '# 011' \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\"
then
lnum=\$( sed '3q;d' \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\" )
lnum=\$( echo \$lnum | sed 's/# 011//g' )
lnum=\$( echo \$lnum | sed 's/ //g' )
echo \$( sed '3q;d' \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\" )
if [[ ! \$lnum -eq 5 ]]
then
lnum=\$((\$lnum+1))
sed -i \"/.*# 011.*/ c\\ \$lnum # 011\" \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\"
else
lnum=1
sed -i \"/.*# 011.*/ c\\ \$lnum # 011\" \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\"
cd \$HOME
cd termuxstyling
git fetch >/dev/null
test=\$(git status | grep 'Your branch')
echo \$test
sleep 5
if [[ ! \$test == *\"up to date\"* ]];
then
updatedw
fi
fi
else
echo hi
echo \"1 # 011\" >> \"/data/data/com.termux/files/home/termuxstyling/.user.cfg\"
fi
else
updatedw
fi
cd
alias md=\"mkdir\"
alias msf=\"msfconsole\"
alias msfdb=\"initdb \$PREFIX/var/lib/postgresql;pg_ctl -D \$PREFIX/var/lib/postgresql start \"
alias clear=\"clear;printf '\e[0m';figlet $uname\"
alias dir=\"ls\"
alias ins=\"pkg install\"
alias ains=\"apt install\"
alias cls=\"clear\"
alias rf=\"rm -rf\"
alias gic=\"git clone\"
alias fuck=\"printf '\e[0m';figlet FUCK;figlet OFF\"
alias upg=\"git reset --hard;git pull\"
alias update=\"apt-get update;apt-get upgrade\"" > /data/data/com.termux/files/usr/etc/bash.bashrc
cd /$HOME
cd termuxstyling
echo Script made by
toilet Dark
toilet Warrior
sleep 2
mdv README.md
cd $pdir
echo Subscribe to our YT channel FemurTech
echo tinyurl.com/femurtech
echo Restart to apply changes