Skip to content

Commit

Permalink
added comments and made reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
SaicharanKandukuri committed Jul 5, 2021
1 parent 2d83172 commit b305bbe
Showing 1 changed file with 69 additions and 42 deletions.
111 changes: 69 additions & 42 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bash

##############
# * Script V01
#
####################################################
# Hippo installer Script V01 (mad installer)
# A script made by @zman-1x1 saicharankandukuri
# Copyright (c) 2021 Saicharan Kandukuri
# hello.1x1.sai@gmail.com


version="01"

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

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


# CACHE_ROOT is the place where are download caches are stored
CACHE_ROOT="${HOME}/.uoa-cache-root"

# TPREFIX where root of termux starts
TPREFIX="/data/data/com.termux/files"
#BIN_DIR="${TPREFIX}/usr/bin"

# BIN_DIR where binary files are stored in termux
# * (like /bin in traditional linux)
BIN_DIR="${TPREFIX}/usr/bin"

# INSTALL_FOLDER variable points to folder location where the file systems are installed in proot-distro
# * used when checking for hippo
INSTALL_FOLDER="${TPREFIX}/usr/var/lib/proot-distro/installed-rootfs"

# HIPPO_DIR variable points to folder where hippo root filesystem is in
HIPPO_DIR="${INSTALL_FOLDER}/hippo"
SCRIPT_DIR="${TPREFIX}/usr/etc/proot-distro"

# SCRIPT_DIR variable points to folder where plugins for proot-distro is stored
# * this is where hippo.sh plugin goes

SCRIPT_DIR="${TPREFIX}/usr/etc/proot-distro/"

# HIPPO_REPO_URL & FSM_URL are github repo urls later used to clone the code
HIPPO_REPO_URL="https://github.com/RandomCoderOrg/ubuntu-on-android"
FSM_URL="https://github.com/RandomCoderOrg/fs-manager-hippo"

# DEPENDS programs required to run Hippo
# * proot-distro - A proot manager tool
# (which starts hippo)
# * git - the stupid content tracker
# (used to copy code from github repo)
# * pulseaudo - PulseAudio is a networked low-latency sound server for Linux
# (which is used to get audio from hippo using moudle-tcp*)
# * Others dependencies like tar comes pre-loaded in termux so no need to mention
DEPENDS="proot-distro pulseaudio git"


# * Usefull functions
# die() exit with code 1 with printing given string
# warn() like die() without exit status (used when exit is not necessary)
# shout() pring messege in a good way with some lines
# lshout() print messege in a standard way

die () { echo -e "${RED}Error ${*}${RST}";exit 1 ;:;}
warn () { echo -e "${RED}Error ${*}${RST}";:;}
shout () { echo -e "${DC}-----";echo -e "${*}";echo -e "-----${RST}";:; }
Expand All @@ -39,45 +77,31 @@ lshout () { echo -e "${DC}";echo -e "${*}";echo -e "${RST}";:; }
shout "\e[1;32m Hippo Installer v${version}"
sleep 2


######################################
# * function setup_and_clone
#
# * die function exits program
# * shout just echo the messege out (fancy one line 😁)
#
# 1. install required programs
# 2. remove previous cache if found
# 3. clone code from links in HIPPO_REPO_URL & FSM_URL
# 4. call install function
# if anything goes wrong or any program in code fails kill the installation by calling die function

function setup_and_clone()
{
shout "Trying to update apt indexes...."
apt update; apt upgrade -y

if ! command -v proot-distro >> /dev/null; then
shout "Installing proot-distro..."
apt install proot-distro -y || {
die "pulseaudio installation failed"
}
lshout "Done..."
fi


if ! command -v git >> /dev/null; then
shout "Installing git.."
apt install git -y || {
die "Git installation failed"
}
lshout "Done..."
fi
for DEP in $DEPENDS
do
if ! command -v "$DEP" >> /dev/null; then
shout "Installing ${DEP}.."
apt install "$DEP" -y || {
die "$DEP installation failed"
}
fi
done

if ! command -v pulseaudio >> /dev/null; then
shout "Installing pulseaudio..."
apt install pulseaudio -y || {
die "pulseaudio installation failed"
}
lshout "Done..."
fi

if ! command -v pv >> /dev/null; then
shout "installing pv.."
apt install pv -y
fi

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

###################################
# * function install
#
# 1. chech for plugin and copy to proot-distro plugin folder
# 2. chech for fs-manager-hippo(hippo) install script in its root directory and run it
# 3. trigger hippo installation
# 4. show echo of installation complete and clear screen
# if anything goes wrong or any program in code fails kill the installation by calling die function

function install()
{
####
# * Step 1

shout "setting up proot-distro hippo implant..."

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

####
# step 2

if [ -f "${CACHE_ROOT}"/fs-manager-hippo/install.sh ]; then
oldpwd="$(pwd)"
cd "${CACHE_ROOT}"/fs-manager-hippo || die "failed to cd ..."
Expand Down

0 comments on commit b305bbe

Please sign in to comment.