@@ -11,6 +11,7 @@ TPREFIX="/data/data/com.termux/files"
1111
1212SCRIPT_DIR=" ${TPREFIX} /usr/etc/proot-distro"
1313INSTALL_FOLDER=" ${TPREFIX} /usr/var/lib/proot-distro/installed-rootfs"
14+ DLCACHE=" ${PREFIX} /usr/var/lib/proot-distro/dlcache"
1415
1516HIPPO_DIR=" ${INSTALL_FOLDER} /udroid"
1617HIPPO_SCRIPT_FILE=" ${SCRIPT_DIR} /udroid.sh"
@@ -27,10 +28,10 @@ HIPPO_SCRIPT_FILE="${SCRIPT_DIR}/udroid.sh"
2728# lshout() print messege in a standard way
2829# msg() print's normal echo
2930
30- die () { echo -e " ${RED} Error ${* }${RST} " ; exit 1 ; : ; }
31- warn () { echo -e " ${RED} Error ${* }${RST} " ; : ; }
32- shout () { echo -e " ${DS} //////// " ; echo -e " ${* } " ; echo -e " //////// ${RST} " ; : ; }
33- lshout () { echo -e " ${DC} " ; echo -e " ${* } " ; echo -e " ${RST} " ; : ; }
31+ die () { echo -e " ${RED} !! ${* }${RST} " ; exit 1 ; : ; }
32+ warn () { echo -e " ${RED} ?? ${* }${RST} " ; : ; }
33+ shout () { echo -e " ${DS} => ${* }${RST} " ; : ; }
34+ lshout () { echo -e " ${DC} -> ${* }${RST} " ; : ; }
3435msg () { echo -e " \e[38;5;228m ${* } \e[0m" >&2 ; : ; }
3536
3637
@@ -43,7 +44,7 @@ function __check_for_hippo() {
4344}
4445
4546function __check_for_plugin() {
46-
47+
4748 if [ -f ${HIPPO_SCRIPT_FILE} ]; then
4849 return 0
4950 else
@@ -65,12 +66,14 @@ function __verify_bin_path()
6566{
6667 BINPATH=" ${SHELL} "
6768
68- if [ -z " $BINPATH " ]; then
69+ if [ -n " $BINPATH " ]; then
6970 if [ " $BINPATH " != " /data/data/com.termux/files/*" ]; then
7071 msg " This has to be done inside termux environment"
7172 die " \$ SHELL != $BINPATH "
7273 exit 1
7374 fi
75+ else
76+ warn " SHELL value is empty.."
7477 fi
7578}
7679
@@ -143,15 +146,41 @@ function __force_uprade_hippo()
143146 bash install.sh || die " failed to install manager..."
144147 fi
145148}
146-
149+ progressfilt ()
150+ {
151+ local flag=false c count cr=$' \r ' nl=$' \n '
152+ while IFS=' ' read -d ' ' -rn 1 c
153+ do
154+ if $flag
155+ then
156+ printf ' %s' " $c "
157+ else
158+ if [[ $c != $cr && $c != $nl ]]
159+ then
160+ count=0
161+ else
162+ (( count++ ))
163+ if (( count > 1 ))
164+ then
165+ flag=true
166+ fi
167+ fi
168+ fi
169+ done
170+ }
171+ _download ()
172+ {
173+ link=$1
174+ wget --progress=bar:force $link || die " download failed"
175+ }
147176function __help()
148177{
149178 msg " udroid - termux Version ${version} by saicharankandukuri"
150- msg
179+ msg
151180 msg " A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project"
152- msg
181+ msg
153182 msg " Usage ${0} [options]"
154- msg
183+ msg
155184 msg " Options:"
156185 msg " --install To try installing udroid"
157186 msg " --help To display this message"
@@ -162,13 +191,55 @@ function __help()
162191 msg " --enable-dbus-startvnc To start vnc with dbus"
163192 msg " ------------------" # links goes here
164193 msg " for additional documentation see: \e[1;34mhttps://github.com/RandomCoderOrg/ubuntu-on-android#basic-usage"
165- msg " report issues and feature requests at: \e[1;34mhttps://github.com/RandomCoderOrg/ubuntu-on-android/issues"
194+ msg " report issues and feature requests at: \e[1;34mhttps://github.com/RandomCoderOrg/ubuntu-on-android/issues"
166195 # msg "Join the community at DISCORD -> $SOCIAL_PLATFORM"
167196 msg " ------------------"
168197}
169198
199+ function __split_tarball_handler()
200+ {
201+ target_plugin=$1
202+ if [ -n " $target_plugin " ] && [ -f " $target_plugin " ]; then
203+ source $target_plugin
204+ else
205+ die " Could not find script in tmp directory: This attribute is not for manuall entry"
206+ fi
207+
208+ if ! $SPLIT_TARBALL_FS ; then
209+ cp " $target_plugin " " $SCRIPT_DIR /udroid.sh"
210+ shift ; _lauch_or_install " $@ "
211+ fi
212+ shout " starting download.. this may take some time"
213+
214+ if [ ! -d ${CACHE_ROOT} ]; then
215+ mkdir -v ${CACHE_ROOT}
216+ fi
217+
218+ mkdir -p " ${CACHE_ROOT} /fs-cache"
219+
220+ # count no.of parts
221+ x=0
222+ for part in $PARTS ; do
223+ (( x= x+ 1 ))
224+ done
225+ cd ${CACHE_ROOT} /fs-cache || die " failed.. cd"
226+ # start download
227+ y=0
228+ for links in $PARTS ; do
229+ (( y= y+ 1 ))
230+ shout " downloading [$( basename $links ) ] part($y /$x ).. "
231+ _download $links
232+ done
233+ cd $HOME || die " failed.. cd"
234+ shout " combining parts to one.. ( ̄︶ ̄)↗"
235+ cat " ${CACHE_ROOT} /fs-cache/*" > " ${DLCACHE} /${FINAL_NAME} "
236+ shout " triggering installation.."
237+ shift ; _lauch_or_install " $@ "
238+ }
239+
170240function _lauch_or_install()
171241{
242+
172243 if ! __check_for_plugin; then
173244 echo -e " Plugin at ${HIPPO_SCRIPT_FILE} is missing ......"
174245 echo -e " May be this not a correct installation...."
@@ -208,7 +279,7 @@ __verify_bin_path
208279if [ $# -ge 1 ]; then
209280 case " $1 " in
210281 upgrade) __upgrade;;
211-
282+ --init-setup-tarball) shift 1 ; __split_tarball_handler " $@ " ;;
212283 --force-upgrade) __force_uprade_hippo;;
213284 --enable-dbus) shift 1; _lauch_or_install --bind /dev/null:/proc/sys/kernel/cap_last_cap " $@ " ;;
214285 " --enable-dbus-startvnc" ) shift 1; _lauch_or_install --bind /dev/null:/proc/sys/kernel/cap_last_cap -- startvnc " $@ " ;;
@@ -225,7 +296,7 @@ if [ $# -ge 1 ]; then
225296 echo -e " \e[32mError:\e[0m udroid not found"
226297 fi
227298 ;;
228-
299+
229300 stoptvnc)
230301 if __check_for_hippo; then
231302 proot-distro login udroid --no-kill-on-exit -- stoptvnc
0 commit comments