From 796da171a22c0dc798fce4dabd6d19018b361120 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Mon, 9 May 2022 21:39:31 +0700 Subject: [PATCH] Add proxytext-wrapper for Termux --- Apps/proxytext/proxytext-wrapper.sh | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 Apps/proxytext/proxytext-wrapper.sh diff --git a/Apps/proxytext/proxytext-wrapper.sh b/Apps/proxytext/proxytext-wrapper.sh new file mode 100755 index 0000000..f705fb0 --- /dev/null +++ b/Apps/proxytext/proxytext-wrapper.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +function check_android () { + if $(uname -o) -ne "Android" + then + return false + fi + return true +} + +function proot_install_dependencies () { + apt update -y + apt install git chromium nodejs npm -y + npm install -g --silent yarn +} + +function proot_install_proxytext () { + echo "Installing proxytext." + git clone https://gitlab.com/tretrauit/proxytext.git + cd proxytext + yarn install +} + +function proot_launch_proxytext () { + echo "Launching proxytext." + cd proxytext + PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium yarn start + exit +} + +function install_dependencies () { + echo "Checking dependencies..." + declare -a dependencies=("proot-distro") + for i in "${dependencies[@]}" + do + if ! [ -x "$(command -v \"$i\")" ]; then + echo "Installing $i..." + pkg install $i + fi + done +} + +function install_dependencies_debian () { + echo "Installing dependencies in Debian proot..." + proot-distro login debian --termux-home -- bash ./proxytext-wrapper.sh --proot --install-dependencies + echo "Done." +} + +function install_debian() { + echo "Installing debian..." + proot-distro install debian +} + +function install_proxytext () { + proot-distro login debian --termux-home -- bash ./proxytext-wrapper.sh --proot --install +} + +function start_proxytext () { + proot-distro login debian --termux-home -- bash ./proxytext-wrapper.sh --proot --launch +} + +if [[ "$1" = "--proot" ]] +then + if [[ "$2" = "--launch" ]] + then + proot_launch_proxytext + elif [[ "$2" = "--install" ]] + then + proot_install_proxytext + elif [[ "$2" = "--install-dependencies" ]] + then + proot_install_dependencies + fi + exit 0 +fi + +if [[ check_android = false ]]; +then + echo "This script only supports Android using Termux." + exit 1 +fi + +install_dependencies +install_debian +install_dependencies_debian +[ ! -d "./proxytext" ] && install_proxytext +echo "Installation completed." +start_proxytext