Skip to content

Commit 7423ed3

Browse files
Merge pull request #11 from RandomCoderOrg/SaicharanKandukuri/issue9
fix #9
2 parents 538b980 + 041e8b5 commit 7423ed3

File tree

6 files changed

+158
-22
lines changed

6 files changed

+158
-22
lines changed

etc/proot-env/vnc/xstartup

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
unset SESSION_MANAGER
33
unset DBUS_SESSION_BUS_ADDRESS
44
export PULSE_SERVER=127.0.0.1
5-
dbus-launch --exit-with-session startxfce4
5+
dbus-launch --exit-with-session startxfce4 &
6+
7+
if command -v plank > /dev/null; then
8+
plank &
9+
fi

etc/proot-env/vnc/xstartup-hdpi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ export PULSE_SERVER=127.0.0.1
55
export GDK_SCALE=2
66
export XCURSOR_SIZE=48
77
export QT_SCALE_FACTOR=2
8-
dbus-lauch --exit-with-session startxfce4
8+
dbus-lauch --exit-with-session startxfce4 &
9+
10+
if command -v plank > /dev/null; then
11+
plank &
12+
fi

etc/scripts/pulseeffects/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# shout() pring messege in a good way with some lines
1515
# lshout() print messege in a standard way
1616

17-
die () { echo -e "${RED}Error ${*}${RST}";exit 1 ;:;}
18-
warn () { echo -e "${RED}Error ${*}${RST}";:;}
19-
shout () { echo -e "${DC}-----";echo -e "${*}";echo -e "-----${RST}";:; }
20-
lshout () { echo -e "${DC}";echo -e "${*}";echo -e "${RST}";:; }
17+
die () { echo -e "${RED}!! ${*}${RST}";exit 1 ;:;}
18+
warn () { echo -e "${RED}?? ${*}${RST}";:;}
19+
shout () { echo -e "${DS}=> ${*}${RST}";:; }
20+
lshout () { echo -e "${DC}-> ${*}${RST}";:; }
2121

2222
###################################################################
2323
# 1. Update apt indexs

etc/scripts/udroid/udroid-proot.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
# Udroid manager to work inside proot environment
4+
#
5+
6+
_init()
7+
{
8+
:
9+
}
10+
######
11+
_set()
12+
{
13+
:
14+
}
15+
16+
_enable()
17+
{
18+
:
19+
}
20+
21+
_start()
22+
{
23+
:
24+
}
25+
26+
_createuser()
27+
{
28+
:
29+
}
30+
######
31+
32+
_start_vnc()
33+
{
34+
:
35+
}
36+
37+
_stop_vnc()
38+
{
39+
:
40+
}
41+
42+
######
43+
44+
_start_services()
45+
{
46+
:
47+
}
48+
49+
_stop_services()
50+
{
51+
:
52+
}
53+
54+
######

etc/scripts/udroid/udroid.sh

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TPREFIX="/data/data/com.termux/files"
1111

1212
SCRIPT_DIR="${TPREFIX}/usr/etc/proot-distro"
1313
INSTALL_FOLDER="${TPREFIX}/usr/var/lib/proot-distro/installed-rootfs"
14+
DLCACHE="${PREFIX}/usr/var/lib/proot-distro/dlcache"
1415

1516
HIPPO_DIR="${INSTALL_FOLDER}/udroid"
1617
HIPPO_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}";:; }
3435
msg () { echo -e "\e[38;5;228m ${*} \e[0m" >&2 ;:; }
3536

3637

@@ -43,7 +44,7 @@ function __check_for_hippo() {
4344
}
4445

4546
function __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+
}
147176
function __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+
170240
function _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
208279
if [ $# -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

etc/scripts/vncserver/startvnc.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ fi
1919

2020
if [ -f /tmp/.X11-unix/X${port} ]; then
2121
vnc=true
22-
elif [ -f /tmp/.X${port}-lock ]; then
23-
vnc=true
2422
else
2523
vnc=false
2624
fi
2725

26+
if [ -f /tmp/.X${port}-lock ]; then
27+
vnc=true
28+
else
29+
vnc=false
30+
fi
2831

2932
if ! $vnc; then
30-
vncserver -xstartup "${DEFAULT_XSTARTUP}" -desktop "udroid Default VNC" :${port}
33+
vncserver -xstartup "${DEFAULT_XSTARTUP}" -localhost no -desktop "udroid Default VNC" :${port}
3134
else
3235
echo "A vncserver lock is found for port ${port}"
3336
echo -e "Use \e[1;32mudroid stoptvnc\e[0m or \e[1;32mstopvnc\e[0m to stop it and try again..."

0 commit comments

Comments
 (0)