Skip to content

Commit b305bbe

Browse files
added comments and made reusable
1 parent 2d83172 commit b305bbe

File tree

1 file changed

+69
-42
lines changed

1 file changed

+69
-42
lines changed

install.sh

+69-42
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env bash
22

3-
##############
4-
# * Script V01
5-
#
3+
####################################################
4+
# Hippo installer Script V01 (mad installer)
5+
# A script made by @zman-1x1 saicharankandukuri
6+
# Copyright (c) 2021 Saicharan Kandukuri
7+
8+
69

710
version="01"
811

@@ -16,20 +19,55 @@ DC=${BLUE}
1619
#GREEN_THIN="\e[32m"
1720

1821
# * Used for testing
22+
# if set then installer clones code from specified branch (sensitive)
1923
if [ -n "$HIPPO_BRANCH" ]; then
2024
BRANCH="$HIPPO_BRANCH"
2125
fi
2226

2327

28+
# CACHE_ROOT is the place where are download caches are stored
2429
CACHE_ROOT="${HOME}/.uoa-cache-root"
30+
31+
# TPREFIX where root of termux starts
2532
TPREFIX="/data/data/com.termux/files"
26-
#BIN_DIR="${TPREFIX}/usr/bin"
33+
34+
# BIN_DIR where binary files are stored in termux
35+
# * (like /bin in traditional linux)
36+
BIN_DIR="${TPREFIX}/usr/bin"
37+
38+
# INSTALL_FOLDER variable points to folder location where the file systems are installed in proot-distro
39+
# * used when checking for hippo
2740
INSTALL_FOLDER="${TPREFIX}/usr/var/lib/proot-distro/installed-rootfs"
41+
42+
# HIPPO_DIR variable points to folder where hippo root filesystem is in
2843
HIPPO_DIR="${INSTALL_FOLDER}/hippo"
29-
SCRIPT_DIR="${TPREFIX}/usr/etc/proot-distro"
44+
45+
# SCRIPT_DIR variable points to folder where plugins for proot-distro is stored
46+
# * this is where hippo.sh plugin goes
47+
48+
SCRIPT_DIR="${TPREFIX}/usr/etc/proot-distro/"
49+
50+
# HIPPO_REPO_URL & FSM_URL are github repo urls later used to clone the code
3051
HIPPO_REPO_URL="https://github.com/RandomCoderOrg/ubuntu-on-android"
3152
FSM_URL="https://github.com/RandomCoderOrg/fs-manager-hippo"
3253

54+
# DEPENDS programs required to run Hippo
55+
# * proot-distro - A proot manager tool
56+
# (which starts hippo)
57+
# * git - the stupid content tracker
58+
# (used to copy code from github repo)
59+
# * pulseaudo - PulseAudio is a networked low-latency sound server for Linux
60+
# (which is used to get audio from hippo using moudle-tcp*)
61+
# * Others dependencies like tar comes pre-loaded in termux so no need to mention
62+
DEPENDS="proot-distro pulseaudio git"
63+
64+
65+
# * Usefull functions
66+
# die() exit with code 1 with printing given string
67+
# warn() like die() without exit status (used when exit is not necessary)
68+
# shout() pring messege in a good way with some lines
69+
# lshout() print messege in a standard way
70+
3371
die () { echo -e "${RED}Error ${*}${RST}";exit 1 ;:;}
3472
warn () { echo -e "${RED}Error ${*}${RST}";:;}
3573
shout () { echo -e "${DC}-----";echo -e "${*}";echo -e "-----${RST}";:; }
@@ -39,45 +77,31 @@ lshout () { echo -e "${DC}";echo -e "${*}";echo -e "${RST}";:; }
3977
shout "\e[1;32m Hippo Installer v${version}"
4078
sleep 2
4179

80+
81+
######################################
82+
# * function setup_and_clone
4283
#
43-
# * die function exits program
44-
# * shout just echo the messege out (fancy one line 😁)
45-
#
84+
# 1. install required programs
85+
# 2. remove previous cache if found
86+
# 3. clone code from links in HIPPO_REPO_URL & FSM_URL
87+
# 4. call install function
88+
# if anything goes wrong or any program in code fails kill the installation by calling die function
4689

4790
function setup_and_clone()
4891
{
4992
shout "Trying to update apt indexes...."
5093
apt update; apt upgrade -y
5194

52-
if ! command -v proot-distro >> /dev/null; then
53-
shout "Installing proot-distro..."
54-
apt install proot-distro -y || {
55-
die "pulseaudio installation failed"
56-
}
57-
lshout "Done..."
58-
fi
59-
60-
61-
if ! command -v git >> /dev/null; then
62-
shout "Installing git.."
63-
apt install git -y || {
64-
die "Git installation failed"
65-
}
66-
lshout "Done..."
67-
fi
95+
for DEP in $DEPENDS
96+
do
97+
if ! command -v "$DEP" >> /dev/null; then
98+
shout "Installing ${DEP}.."
99+
apt install "$DEP" -y || {
100+
die "$DEP installation failed"
101+
}
102+
fi
103+
done
68104

69-
if ! command -v pulseaudio >> /dev/null; then
70-
shout "Installing pulseaudio..."
71-
apt install pulseaudio -y || {
72-
die "pulseaudio installation failed"
73-
}
74-
lshout "Done..."
75-
fi
76-
77-
if ! command -v pv >> /dev/null; then
78-
shout "installing pv.."
79-
apt install pv -y
80-
fi
81105

82106
if [ -d "${CACHE_ROOT}" ]; then
83107
shout "Removing old cache......."
@@ -98,11 +122,17 @@ function setup_and_clone()
98122
install
99123
}
100124

125+
###################################
126+
# * function install
127+
#
128+
# 1. chech for plugin and copy to proot-distro plugin folder
129+
# 2. chech for fs-manager-hippo(hippo) install script in its root directory and run it
130+
# 3. trigger hippo installation
131+
# 4. show echo of installation complete and clear screen
132+
# if anything goes wrong or any program in code fails kill the installation by calling die function
133+
101134
function install()
102135
{
103-
####
104-
# * Step 1
105-
106136
shout "setting up proot-distro hippo implant..."
107137

108138
sleep 3
@@ -115,9 +145,6 @@ function install()
115145
cp "${CACHE_ROOT}"/ubuntu-on-android/hippo.sh ${SCRIPT_DIR}
116146
fi
117147

118-
####
119-
# step 2
120-
121148
if [ -f "${CACHE_ROOT}"/fs-manager-hippo/install.sh ]; then
122149
oldpwd="$(pwd)"
123150
cd "${CACHE_ROOT}"/fs-manager-hippo || die "failed to cd ..."

0 commit comments

Comments
 (0)