11#! /usr/bin/env bash
22
3- version=1
3+ version=2
44
55if [ -n " $HIPPO_BRANCH " ]; then
66 BRANCH=" $HIPPO_BRANCH "
@@ -20,11 +20,18 @@ SOCIAL_PLATFORM="\e[1;34mhttps://discord.gg/TAqaG5sEfW\e[0m"
2020# HIPPO_DIR = "${INSTALL_FOLDER}/${HIPPO_DEFAULT}"
2121# HIPPO_SCRIPT_FILE="${SCRIPT_DIR}/hippo.sh"
2222
23+ # * Usefull functions
24+ # die() exit with code 1 with printing given string
25+ # warn() like die() without exit status (used when exit is not necessary)
26+ # shout() pring messege in a good way with some lines
27+ # lshout() print messege in a standard way
28+ # msg() print's normal echo
2329
2430die () { echo -e " ${RED} Error ${* }${RST} " ; exit 1 ; : ; }
2531warn () { echo -e " ${RED} Error ${* }${RST} " ; : ; }
2632shout () { echo -e " ${DS} ////////" ; echo -e " ${* } " ; echo -e " ////////${RST} " ; : ; }
2733lshout () { echo -e " ${DC} " ; echo -e " ${* } " ; echo -e " ${RST} " ; : ; }
34+ msg () { echo -e " ${@ } " >&2 ; : ; }
2835
2936
3037function __check_for_hippo() {
@@ -54,6 +61,18 @@ function __check_for_filesystem() {
5461 fi
5562}
5663
64+ function __verify_bin_path()
65+ {
66+ BINPATH=" ${SHELL} "
67+
68+ if [ -z " $BINPATH " ]; then
69+ if [ " $BINPATH " == " /data/data/com.termux/files/*" ]; then
70+ msg " This has to be done inside termux environment"
71+ die " \$ SHELL != $BINPATH "
72+ fi
73+ fi
74+ }
75+
5776function __upgrade() {
5877 # setup downloader
5978 if ! command -v axel >> /dev/null; then
@@ -62,28 +81,28 @@ function __upgrade() {
6281
6382 mkdir -p " ${CACHE_ROOT} "
6483 axel -o " ${CACHE_ROOT} " /version https://raw.githubusercontent.com/RandomCoderOrg/fs-manager-hippo/main/version >> /dev/null || {
65- echo " Error " ; exit 1
84+ die " error "
6685 }
6786
6887 origin_version=$( cat " ${CACHE_ROOT} " /version)
6988
7089 rm -rf " ${CACHE_ROOT} "
7190
7291 if [ " $origin_version " -gt " $version " ]; then
73- echo -e " upgrdae avalibe to \e[1;32mV${origin_version} \e[0m"
92+ lshout " upgrdae avalibe to \e[1;32mV${origin_version} \e[0m"
7493 elif [ " $origin_version " -eq " $version " ]; then
75- echo -e " You are on latest version \e[1;32mV${origin_version} \e[0m"
94+ lshout " You are on latest version \e[1;32mV${origin_version} \e[0m"
7695 exit 0
7796 else
78- echo " Upgrader hit unexpected condition..."
97+ die " Upgrader hit unexpected condition..."
7998 exit 1
8099 fi
81100
82101 if start_upgrade; then
83102 bash -x " ${CACHE_ROOT} " /upgrade --summary
84103 rm -rf " ${CACHE_ROOT} "
85104 else
86- echo " Error"
105+ die " Error"
87106 fi
88107
89108
@@ -92,7 +111,7 @@ function __upgrade() {
92111function start_upgrade() {
93112 mkdir -p " ${CACHE_ROOT} "
94113 axel -o " ${CACHE_ROOT} " /upgrade.sh https://raw.githubusercontent.com/RandomCoderOrg/fs-manager-hippo/main/etc/scripts/upgrade_patch/upgrade.sh >> /dev/null || {
95- echo " Error" ; exit 1
114+ die " Error" ; exit 1
96115 }
97116 bash -x upgrade.sh || {
98117 return 1
@@ -126,23 +145,22 @@ function __force_uprade_hippo()
126145
127146function __help()
128147{
129- echo -e " hippo - termux Version ${version} "
130- echo -e " A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project"
131- echo -e
132- echo -e " Usage ${0} [options]"
133- echo -e
134- echo -e " Options:"
135- echo -e " \e[1;34m"
136- echo -e " --install To try installing hippo"
137- echo -e " --help to display this message"
138- echo -e " --enable-dbus To start terminal session with dbus enabled"
139- echo -e " startvnc To start hippo vncserver"
140- echo -e " stopvnc To stop hippo vncserver"
141- echo -e " ------------------"
142- # SOCIAL_MEDIA link goes here
143- echo -e " Join the community and leave at DISCORD -> $SOCIAL_PLATFORM "
144- echo -e " ------------------"
145- echo -e " \e[0m"
148+ msg " hippo - termux Version ${version} "
149+ msg " A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project"
150+ msg
151+ msg " Usage ${0} [options]"
152+ msg
153+ msg " Options:"
154+ msg " \e[1;34m"
155+ msg " --install To try installing hippo"
156+ msg " --help to display this message"
157+ msg " --enable-dbus To start terminal session with dbus enabled"
158+ # msg "startvnc To start hippo vncserver"
159+ # msg "stopvnc To stop hippo vncserver"
160+ msg " ------------------" # SOCIAL_MEDIA link goes here
161+ msg " Join the community and leave at DISCORD -> $SOCIAL_PLATFORM "
162+ msg " ------------------"
163+ msg " \e[0m"
146164}
147165
148166function _lauch_or_install()
@@ -156,7 +174,7 @@ function _lauch_or_install()
156174 if ! __check_for_filesystem; then
157175 echo -e " Installing hippo..........."
158176 if proot-distro install hippo; then
159- echo -e " Installation Done......\a\a"
177+ echo -e " Installation Done......\a\a" # \a triggers vibration in termux
160178 echo " Waiting..."
161179 sleep 4
162180 clear
@@ -169,20 +187,20 @@ function _lauch_or_install()
169187
170188
171189 pulseaudio --start --load=" module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1 >> /dev/null
172- if [[ -f " ${CACHE_ROOT} " /fs-manager-hippo/etc/scripts/vncserver/startvnc.sh ]] && [[ ! -f ${HIPPO_DIR} /bin/startvnc ]]; then
173- DIR=" ${CACHE_ROOT} /fs-manager-hippo/etc/scripts/vncserver/startvnc.sh"
174- cp " ${DIR} " ${HIPPO_DIR} /bin/startvnc
175- proot-distro login hippo -- chmod 775 /bin/startvnc
176- fi
177- if [ -f " ${CACHE_ROOT} " /fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh ] && [ ! -f ${HIPPO_DIR} /bin/stopvnc ]; then
178- DIR=" ${CACHE_ROOT} /fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh"
179- cp " ${DIR} " ${HIPPO_DIR} /bin/stopvnc
180- proot-distro login hippo -- chmod 775 /bin/stopvnc
181- fi
190+ # if [[ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh ]] && [[ ! -f ${HIPPO_DIR}/bin/startvnc ]]; then
191+ # DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh"
192+ # cp "${DIR}" ${HIPPO_DIR}/bin/startvnc
193+ # proot-distro login hippo -- chmod 775 /bin/startvnc
194+ # fi
195+ # if [ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh ] && [ ! -f ${HIPPO_DIR}/bin/stopvnc ]; then
196+ # DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh"
197+ # cp "${DIR}" ${HIPPO_DIR}/bin/stopvnc
198+ # proot-distro login hippo -- chmod 775 /bin/stopvnc
199+ # fi
182200 proot-distro login hippo " $@ " || warn " program exited unexpectedly..."
183201 fi
184202}
185-
203+ __verify_bin_path
186204if [ $# -ge 1 ]; then
187205 case " $1 " in
188206 upgrade) __upgrade;;
@@ -194,25 +212,25 @@ if [ $# -ge 1 ]; then
194212 --install) _lauch_or_install;;
195213 --help) __help;;
196214
197- startvnc)
198- if __check_for_hippo; then
199- proot-distro login hippo -- startvnc
200- else
201- echo -e " This command is supposed to run after installing hippo"
202- # echo -e "Use \e[1;32mhippo --install\e[0m install"
203- echo -e " \e[32mError:\e[0m Hippo not found"
204- fi
205- ;;
215+ # startvnc)
216+ # if __check_for_hippo; then
217+ # proot-distro login hippo -- startvnc
218+ # else
219+ # echo -e "This command is supposed to run after installing hippo"
220+ # # echo -e "Use \e[1;32mhippo --install\e[0m install"
221+ # echo -e "\e[32mError:\e[0m Hippo not found"
222+ # fi
223+ # ;;
206224
207- stoptvnc)
208- if __check_for_hippo; then
209- proot-distro login hippo -- stoptvnc
210- else
211- echo -e " This command is supposed to run after installing hippo"
212- # echo -e "Use \e[1;32mhippo --install\e[0m install"
213- echo -e " \e[32mError:\e[0m Hippo not found"
214- fi
215- ;;
225+ # stoptvnc)
226+ # if __check_for_hippo; then
227+ # proot-distro login hippo -- stoptvnc
228+ # else
229+ # echo -e "This command is supposed to run after installing hippo"
230+ # # echo -e "Use \e[1;32mhippo --install\e[0m install"
231+ # echo -e "\e[32mError:\e[0m Hippo not found"
232+ # fi
233+ # ;;
216234 * ) _lauch_or_install " $@ " ;;
217235 esac
218236else
0 commit comments