@@ -4,6 +4,7 @@ TERMUX="/data/data/com.termux/files"
44D_SCRIPTS=" ${TERMUX} /usr/etc/proot-distro"
55D_INSTALLED_ROOTFS=" ${TERMUX} /usr/var/lib/proot-distro/installed-rootfs"
66D_CACHCE=" ${HOME} /.udroid-cache-root"
7+ LOGIN_CACHE_FILE=" ${D_CACHCE} /login_rec.cache"
78
89_c_magneta=" \e[95m"
910_c_green=" \e[32m"
@@ -15,51 +16,65 @@ die() { echo -e "${_c_red}[E] ${*}${RST}";exit 1;:;}
1516warn () { echo -e " ${_c_red} [W] ${* }${RST} " ; : ; }
1617shout () { echo -e " ${_c_blue} [-] ${* }${RST} " ; : ; }
1718lshout () { echo -e " ${_c_blue} -> ${* }${RST} " ; : ; }
19+ imsg () { if $UDROID_VERBOSE ; then echo -e " : ${* } \e[0m" >&2 ; fi ; : ; }
1820msg () { echo -e " ${* } \e[0m" >&2 ; : ; }
1921
2022_login () {
21- case $1 in
22- mate) SUITE=" mate" shift ;;
23- xfce|xfce4) SUITE=" xfce4" shift ;;
24- kde) SUITE=" kde" shift ;;
25- * ) l_login $* ;;
26- esac
2723
28- if [ $# -gt 0 ]; then
29- extra_args=$*
24+ varient=$1 ; shift
25+ extra_args=$*
26+
27+ cd " $D_INSTALLED_ROOTFS " || die " $D_INSTALLED_ROOTFS Not Found.."
28+ avalible_distros=$( find $D_INSTALLED_ROOTFS -maxdepth 1 -type d | grep udroid)
29+ cd " $OLDPWD " || exit
30+
31+ if [ -n " $UDROID_SUITE " ]; then
32+ default_suite=" impish"
33+ else
34+ msg " udroid suite [\$ UDROID_SUITE] is set to ${UDROID_SUITE} "
3035 fi
3136
32- suite=" udroid-impish-$SUITE "
37+ distro=" ${default_suite} -${varient} "
38+ if [[ $avalible_distros =~ $distro ]]; then
39+ # store distro aliases in cache
40+ echo " $distro " > " $LOGIN_CACHE_FILE "
3341
34- if is_installed $suite ; then
35- l_cache " $suite "
36-
37- pulseaudio \
38- --start \
39- --load=" module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" \
40- --exit-idle-time=-1 >> /dev/null
41-
42- proot-distro login udroid \
43- --bind /dev/null:/proc/sys/kernel/cap_last_cap \
44- --shared-tmp \
45- $extra_args
42+ # start distro
43+ start " ${default_suite} -${varient} " $extra_args
4644 else
47- msg " looks like $SUITE is not installed. "
48- msg " use udroid -i $SUITE "
45+ # TODO: ADD SUGGESTIONS
46+ lwarn " $distro not found... "
4947 fi
48+ }
49+
50+ start () {
51+
52+ distro=$1 ; shift
53+ extra_args=" --bind /dev/null:/proc/sys/kernel/cap_last_cap \
54+ --shared-tmp \
55+ $extra_args "
5056
57+ # start Pulse Audio tcp receiver
58+
59+ imsg " Starting pulseaudio"
60+
61+ # TODO: CHECK IS Pulseaudio RUNNING BEFORE EXECUTING
62+ pulseaudio \
63+ --start \
64+ --load=" module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" \
65+ --exit-idle-time=-1 >> /dev/null
66+
67+ imsg " Starting $distro .."
68+ proot-distro login " $distro " " $extra_args "
5169}
5270
5371l_login () {
54- if [ -f " ${HOME} /.udroid/logindistro_cache" ]; then
55- if [ -s " ${HOME} /.udroid/logindistro_cache" ]; then
56- login " $( ${HOME} /.udroid/logindistro_cache) " $*
57- fi
58- else
59- _msg " login"
72+ if [ -f " $LOGIN_CACHE_FILE " ]; then
73+ start " $( cat LOGIN_CACHE_FILE) "
6074 fi
6175}
6276
77+
6378_install () {
6479 SUITE=$1
6580
@@ -159,14 +174,6 @@ is_installed() {
159174 return 0
160175}
161176
162- l_cache () {
163- if [ ! -d ${HOME} /.udroid ]; then
164- mkdir ${HOME} /.udroid
165- fi
166-
167- cat $1 > ${HOME} /.udroid/logindistro_cache
168- }
169-
170177download () {
171178 url=$1
172179 location=$2
0 commit comments