From 6fc365b794ff8916602d81ef814a5f2ce98aabf7 Mon Sep 17 00:00:00 2001 From: zman-1x1 Date: Sat, 17 Jul 2021 08:02:32 +0530 Subject: [PATCH] made changes in: hippo fs manager: added termux lock to run script only in termux(203) VNCSERVER shrocuts are commented (tuned off) some script enchangements pulseeffetct/install.sh added comments and attribution version number change --- etc/scripts/hippo/hippo.sh | 126 ++++++++++++++++------------ etc/scripts/pulseeffects/install.sh | 13 +++ version | 2 +- 3 files changed, 86 insertions(+), 55 deletions(-) diff --git a/etc/scripts/hippo/hippo.sh b/etc/scripts/hippo/hippo.sh index 195af5e..a9097b5 100644 --- a/etc/scripts/hippo/hippo.sh +++ b/etc/scripts/hippo/hippo.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version=1 +version=2 if [ -n "$HIPPO_BRANCH" ]; then BRANCH="$HIPPO_BRANCH" @@ -20,11 +20,18 @@ SOCIAL_PLATFORM="\e[1;34mhttps://discord.gg/TAqaG5sEfW\e[0m" # HIPPO_DIR = "${INSTALL_FOLDER}/${HIPPO_DEFAULT}" # HIPPO_SCRIPT_FILE="${SCRIPT_DIR}/hippo.sh" +# * 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 +# msg() print's normal echo die () { echo -e "${RED}Error ${*}${RST}";exit 1 ;:;} warn () { echo -e "${RED}Error ${*}${RST}";:;} shout () { echo -e "${DS}////////";echo -e "${*}";echo -e "////////${RST}";:; } lshout () { echo -e "${DC}";echo -e "${*}";echo -e "${RST}";:; } +msg () { echo -e "${@}" >&2 ;:; } function __check_for_hippo() { @@ -54,6 +61,18 @@ function __check_for_filesystem() { fi } +function __verify_bin_path() +{ + BINPATH="${SHELL}" + + if [ -z "$BINPATH" ]; then + if [ "$BINPATH" == "/data/data/com.termux/files/*" ]; then + msg "This has to be done inside termux environment" + die "\$SHELL != $BINPATH" + fi + fi +} + function __upgrade() { # setup downloader if ! command -v axel >> /dev/null; then @@ -62,7 +81,7 @@ function __upgrade() { mkdir -p "${CACHE_ROOT}" axel -o "${CACHE_ROOT}"/version https://raw.githubusercontent.com/RandomCoderOrg/fs-manager-hippo/main/version >> /dev/null || { - echo "Error"; exit 1 + die "error" } origin_version=$(cat "${CACHE_ROOT}"/version) @@ -70,12 +89,12 @@ function __upgrade() { rm -rf "${CACHE_ROOT}" if [ "$origin_version" -gt "$version" ]; then - echo -e "upgrdae avalibe to \e[1;32mV${origin_version}\e[0m" + lshout "upgrdae avalibe to \e[1;32mV${origin_version}\e[0m" elif [ "$origin_version" -eq "$version" ]; then - echo -e "You are on latest version \e[1;32mV${origin_version}\e[0m" + lshout "You are on latest version \e[1;32mV${origin_version}\e[0m" exit 0 else - echo "Upgrader hit unexpected condition..." + die "Upgrader hit unexpected condition..." exit 1 fi @@ -83,7 +102,7 @@ function __upgrade() { bash -x "${CACHE_ROOT}"/upgrade --summary rm -rf "${CACHE_ROOT}" else - echo "Error" + die "Error" fi @@ -92,7 +111,7 @@ function __upgrade() { function start_upgrade() { mkdir -p "${CACHE_ROOT}" axel -o "${CACHE_ROOT}"/upgrade.sh https://raw.githubusercontent.com/RandomCoderOrg/fs-manager-hippo/main/etc/scripts/upgrade_patch/upgrade.sh >> /dev/null || { - echo "Error"; exit 1 + die "Error"; exit 1 } bash -x upgrade.sh || { return 1 @@ -126,23 +145,22 @@ function __force_uprade_hippo() function __help() { - echo -e "hippo - termux Version ${version}" - echo -e "A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project" - echo -e - echo -e "Usage ${0} [options]" - echo -e - echo -e "Options:" - echo -e "\e[1;34m" - echo -e "--install To try installing hippo" - echo -e "--help to display this message" - echo -e "--enable-dbus To start terminal session with dbus enabled" - echo -e "startvnc To start hippo vncserver" - echo -e "stopvnc To stop hippo vncserver" - echo -e "------------------" - # SOCIAL_MEDIA link goes here - echo -e "Join the community and leave at DISCORD -> $SOCIAL_PLATFORM" - echo -e "------------------" - echo -e "\e[0m" + msg "hippo - termux Version ${version}" + msg "A bash script to make basic action(login, vncserver) easier for ubuntu-on-android project" + msg + msg "Usage ${0} [options]" + msg + msg "Options:" + msg "\e[1;34m" + msg "--install To try installing hippo" + msg "--help to display this message" + msg "--enable-dbus To start terminal session with dbus enabled" + # msg "startvnc To start hippo vncserver" + # msg "stopvnc To stop hippo vncserver" + msg "------------------" #SOCIAL_MEDIA link goes here + msg "Join the community and leave at DISCORD -> $SOCIAL_PLATFORM" + msg "------------------" + msg "\e[0m" } function _lauch_or_install() @@ -156,7 +174,7 @@ function _lauch_or_install() if ! __check_for_filesystem; then echo -e "Installing hippo..........." if proot-distro install hippo; then - echo -e "Installation Done......\a\a" + echo -e "Installation Done......\a\a" # \a triggers vibration in termux echo "Waiting..." sleep 4 clear @@ -169,20 +187,20 @@ function _lauch_or_install() pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1 >> /dev/null - if [[ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh ]] && [[ ! -f ${HIPPO_DIR}/bin/startvnc ]]; then - DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh" - cp "${DIR}" ${HIPPO_DIR}/bin/startvnc - proot-distro login hippo -- chmod 775 /bin/startvnc - fi - if [ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh ] && [ ! -f ${HIPPO_DIR}/bin/stopvnc ]; then - DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh" - cp "${DIR}" ${HIPPO_DIR}/bin/stopvnc - proot-distro login hippo -- chmod 775 /bin/stopvnc - fi + # if [[ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh ]] && [[ ! -f ${HIPPO_DIR}/bin/startvnc ]]; then + # DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/startvnc.sh" + # cp "${DIR}" ${HIPPO_DIR}/bin/startvnc + # proot-distro login hippo -- chmod 775 /bin/startvnc + # fi + # if [ -f "${CACHE_ROOT}"/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh ] && [ ! -f ${HIPPO_DIR}/bin/stopvnc ]; then + # DIR="${CACHE_ROOT}/fs-manager-hippo/etc/scripts/vncserver/stopvnc.sh" + # cp "${DIR}" ${HIPPO_DIR}/bin/stopvnc + # proot-distro login hippo -- chmod 775 /bin/stopvnc + # fi proot-distro login hippo "$@" || warn "program exited unexpectedly..." fi } - +__verify_bin_path if [ $# -ge 1 ]; then case "$1" in upgrade) __upgrade;; @@ -194,25 +212,25 @@ if [ $# -ge 1 ]; then --install) _lauch_or_install;; --help) __help;; - startvnc) - if __check_for_hippo; then - proot-distro login hippo -- startvnc - else - echo -e "This command is supposed to run after installing hippo" - # echo -e "Use \e[1;32mhippo --install\e[0m install" - echo -e "\e[32mError:\e[0m Hippo not found" - fi - ;; + # startvnc) + # if __check_for_hippo; then + # proot-distro login hippo -- startvnc + # else + # echo -e "This command is supposed to run after installing hippo" + # # echo -e "Use \e[1;32mhippo --install\e[0m install" + # echo -e "\e[32mError:\e[0m Hippo not found" + # fi + # ;; - stoptvnc) - if __check_for_hippo; then - proot-distro login hippo -- stoptvnc - else - echo -e "This command is supposed to run after installing hippo" - # echo -e "Use \e[1;32mhippo --install\e[0m install" - echo -e "\e[32mError:\e[0m Hippo not found" - fi - ;; + # stoptvnc) + # if __check_for_hippo; then + # proot-distro login hippo -- stoptvnc + # else + # echo -e "This command is supposed to run after installing hippo" + # # echo -e "Use \e[1;32mhippo --install\e[0m install" + # echo -e "\e[32mError:\e[0m Hippo not found" + # fi + # ;; *) _lauch_or_install "$@";; esac else diff --git a/etc/scripts/pulseeffects/install.sh b/etc/scripts/pulseeffects/install.sh index e1bd4ff..f8fe1da 100644 --- a/etc/scripts/pulseeffects/install.sh +++ b/etc/scripts/pulseeffects/install.sh @@ -1,5 +1,13 @@ #!/usr/bin/env bash +################################################################ +# A script to install pulse effects in Debian/ubuntu systems +# Copyright (c) 2021 1x1-RC Org +# Copyright (c) zman-1x1 +# package installer used: +# * "apt" at lines (25,32) +# + # * Usefull functions # die() exit with code 1 with printing given string # warn() like die() without exit status (used when exit is not necessary) @@ -11,6 +19,11 @@ warn () { echo -e "${RED}Error ${*}${RST}";:;} shout () { echo -e "${DC}-----";echo -e "${*}";echo -e "-----${RST}";:; } lshout () { echo -e "${DC}";echo -e "${*}";echo -e "${RST}";:; } +################################################################### +# 1. Update apt indexs +# 2. install pulseeffcts +# 3. startpulsle effetcs with a 9 seconds wait time +# -> it any condition returns non zero or command internal error script fails shout "trying to update indexes........." apt update; apt upgrade -y || { warn "failed to update indexes..." diff --git a/version b/version index c227083..d8263ee 100644 --- a/version +++ b/version @@ -1 +1 @@ -0 \ No newline at end of file +2 \ No newline at end of file