forked from SDRausty/au
-
Notifications
You must be signed in to change notification settings - Fork 0
/
au
executable file
路24 lines (24 loc) 路 1.92 KB
/
au
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env sh
# Copyright 2017-2022 (c) all rights reserved by SDRausty, please see LICENSE.
# https://sdrausty.github.io/au Contributors: Glow/frumpylava, Hax4us
# In order to save native space on device the path /storage/emulated/0/Android/data/com.termux/txdebs can be changed to a microSDcard destination.
# dpkg --purge name.pkg ; dpkg --install name.pkg # can downgrade packages
################################################################################
set -eu
_AUDIR_ () { [ -e /storage/emulated/0/Android/data/com.termux/txdebs ] || { cd /storage/emulated/0/Android/data/com.termux/ && mkdir -p txdebs ; } || _PRIT_ printf '%s' "Please create directory '/storage/emulated/0/Android/data/com.termux/' in Android. If an external micro sdcard is being used, '/storage/1234-5678/Android/{data,media}/com.termux/' can be used after modifying the path in the ${0##*/} command; " ; }
# update, upgrade and then install packages if any or print message
_AUGET_ () { { apt update && apt -o APT::Keep-Downloaded-Packages="true" upgrade -y && apt -o APT::Keep-Downloaded-Packages="true" install "$@" -y && find /data/data/com.termux/cache/apt/archives/ -maxdepth 1 -type f -name "*.deb" -exec mv -f {} /storage/emulated/0/Android/data/com.termux/txdebs/ \; ; } || printf "\\n%s\\n\\n" "Something unexpected occured; Please study the first lines of the error output, and run ${0##*/} again to install and auto update packages!" ; }
_PD_ () { _PRNT_ "Command '${0##*/}': DONE" ; }
_PRIT_ () { printf "%s" "$1" ; } # print message with no trialing newline
_PRNT_ () { printf "%s\\n" "$1" ; } # print message with one trialing newline
_PB_ () { _PRNT_ "Command '${0##*/}': BEGUN... " ; }
set +e
PVAR="$(ping -n 1 1.1.1.1 2>&1)"
set -e
if [ -n "${PVAR##*unreachable*}" ]
then
_PB_ && _AUDIR_ && _AUGET_ "$@" && _PD_
else
_PB_ && _PRIT_ "$PVAR; Please check your wireless connection and run '${0##*/}' again. Exiting..." && _PD_
fi
# SDRausty/au FE