File tree 1 file changed +30
-9
lines changed
1 file changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -265,16 +265,37 @@ ${orange}Tool By Sauraj (@Ksauraj)${normal}
265
265
"
266
266
}
267
267
268
+ _update_copy () {
269
+ local file=$1
270
+ if declare -p TERMUX_VERSION & > /dev/null; then
271
+ cp " $file " " $PREFIX /bin"
272
+ else
273
+ sudo cp " $file " /usr/local/bin
274
+ fi
275
+ }
276
+
268
277
update () {
269
- echo " ${orange} Current" " $( ksau version) "
270
- echo " ${orange} Fetching latest version.${normal} "
271
- curl https://raw.githubusercontent.com/noobyysauraj/global_index_source/master/ksau > ksau 2> /dev/null
272
- sudo rm /usr/local/bin/ksau
273
- sudo mv ksau /usr/local/bin
274
- chmod +x /usr/local/bin/ksau
275
- echo " ${orange} Update Finished${normal} "
276
- echo " ${orange} Updated to" " $( ksau version) "
277
- echo " ${normal} "
278
+ if ! ping -c2 google.com & > /dev/null; then
279
+ echo " Please check your internet connection"
280
+ return
281
+ fi
282
+
283
+ local tmpfilename new_version new_version_string
284
+ tmpfilename=ksau-$RANDOM
285
+
286
+ echo " Fetching"
287
+ curl --progress-bar -Lo " $tmpfilename " https://raw.githubusercontent.com/noobyysauraj/global_index_source/master/ksau
288
+
289
+ new_version=$( grep ' KSAU_VERSION=' " $tmpfilename " | head -n1 | cut -d= -f2)
290
+ new_version_string=$( grep ' KSAU_VERSION_STRING=' " $tmpfilename " | head -n1 | cut -d= -f2)
291
+ if [[ $new_version -gt $KSAU_VERSION ]]; then
292
+ echo " New version found $Cyan ($KSAU_VERSION_STRING -> $new_version_string )$Normal "
293
+ _update_copy " $tmpfilename "
294
+ else
295
+ echo " Already on latest release."
296
+ fi
297
+
298
+ rm -f " $tmpfilename "
278
299
}
279
300
280
301
version () {
You can’t perform that action at this time.
0 commit comments