@@ -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"
@@ -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
@@ -143,15 +144,41 @@ function __force_uprade_hippo()
143144 bash install.sh || die " failed to install manager..."
144145 fi
145146}
146-
147+ progressfilt ()
148+ {
149+ local flag=false c count cr=$' \r ' nl=$' \n '
150+ while IFS=' ' read -d ' ' -rn 1 c
151+ do
152+ if $flag
153+ then
154+ printf ' %s' " $c "
155+ else
156+ if [[ $c != $cr && $c != $nl ]]
157+ then
158+ count=0
159+ else
160+ (( count++ ))
161+ if (( count > 1 ))
162+ then
163+ flag=true
164+ fi
165+ fi
166+ fi
167+ done
168+ }
169+ _download ()
170+ {
171+ link=$1
172+ wget --progress=bar:force $link || die " download failed"
173+ }
147174function __help()
148175{
149176 msg " udroid - termux Version ${version} by saicharankandukuri"
150- msg
177+ msg
151178 msg " A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project"
152- msg
179+ msg
153180 msg " Usage ${0} [options]"
154- msg
181+ msg
155182 msg " Options:"
156183 msg " --install To try installing udroid"
157184 msg " --help To display this message"
@@ -162,13 +189,57 @@ function __help()
162189 msg " --enable-dbus-startvnc To start vnc with dbus"
163190 msg " ------------------" # links goes here
164191 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"
192+ msg " report issues and feature requests at: \e[1;34mhttps://github.com/RandomCoderOrg/ubuntu-on-android/issues"
166193 # msg "Join the community at DISCORD -> $SOCIAL_PLATFORM"
167194 msg " ------------------"
168195}
169196
197+ function __split_tarball_handler()
198+ {
199+ target_plugin=$1
200+ if [ -n " $target_plugin " ] && [ -f " $target_plugin " ]; then
201+ source $target_plugin
202+ else
203+ die " Could not find script in tmp directory: This attribute is not for manuall entry"
204+ fi
205+
206+ if $SPLIT_TARBALL_FS ; then
207+ :
208+ else
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