From 7ec36a45486c2c3548774559f62bac452b320861 Mon Sep 17 00:00:00 2001 From: thedragonsinn <98635854+thedragonsinn@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:22:16 +0530 Subject: [PATCH] add scripts to easily install reqs for dual mode switch and termux --- Dockerfile | 2 +- docker_start.sh | 39 ++++++++++++++++++++++++++++++++++ docker_start_cmd | 9 -------- req.txt | 5 +++-- scripts/install_termux_reqs.sh | 12 +++++++++++ scripts/install_ub_core.sh | 7 ++++++ 6 files changed, 62 insertions(+), 12 deletions(-) create mode 100755 docker_start.sh delete mode 100644 docker_start_cmd create mode 100755 scripts/install_termux_reqs.sh create mode 100755 scripts/install_ub_core.sh diff --git a/Dockerfile b/Dockerfile index 82a5a57..f8a3ff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,4 +15,4 @@ RUN sed -i.bak 's/us-west-2\.ec2\.//' /etc/apt/sources.list && \ EXPOSE 8080 -CMD bash -c "$(curl -fsSL https://raw.githubusercontent.com/thedragonsinn/plain-ub/main/docker_start_cmd)" \ No newline at end of file +CMD bash -c "$(curl -fsSL https://raw.githubusercontent.com/thedragonsinn/plain-ub/main/docker_start.sh)" \ No newline at end of file diff --git a/docker_start.sh b/docker_start.sh new file mode 100755 index 0000000..b58e980 --- /dev/null +++ b/docker_start.sh @@ -0,0 +1,39 @@ +#!bin/sh + +export PIP_ROOT_USER_ACTION=ignore + +if [ -d "ubot" ]; then + rm -rf ubot + echo "removed older ubot dir" +fi + +run_extra_boot_scripts() { + local directory="scripts" + + if [[ -d "$directory" ]]; then + + if [[ -n "$(ls -A "$directory")" ]]; then + + for file in "$directory"/*; do + + if [[ -f "$file" && -x "$file" ]]; then + + echo "Executing $file" + "$file" + + fi + done + fi + fi +} + + +echo "${GH_TOKEN}" > ~/.git-credentials +git config --global credential.helper store + +git clone -q --depth=1 "${UPSTREAM_REPO:-"https://github.com/thedragonsinn/plain-ub"}" ubot +cd ubot +pip -q install --no-cache-dir -r req*.txt +run_extra_boot_scripts + +bash run diff --git a/docker_start_cmd b/docker_start_cmd deleted file mode 100644 index d60fc73..0000000 --- a/docker_start_cmd +++ /dev/null @@ -1,9 +0,0 @@ -#!bin/sh - -echo "${GH_TOKEN}" > ~/.git-credentials -git config --global credential.helper store - -git clone -q --depth=1 "${UPSTREAM_REPO:-"https://github.com/thedragonsinn/plain-ub"}" ubot -cd ubot -pip -q install --no-cache-dir -r req*.txt -bash run diff --git a/req.txt b/req.txt index 05525a3..f85fa90 100644 --- a/req.txt +++ b/req.txt @@ -1,7 +1,8 @@ # BoilerPlate Code for UB -git+https://github.com/thedragonsinn/ub-core.git +# git+https://github.com/thedragonsinn/ub-core.git +# moved to scripts/install_ub_core.sh -yt-dlp>=2024.4.9 +yt-dlp>=2024.5.27 pillow google-generativeai diff --git a/scripts/install_termux_reqs.sh b/scripts/install_termux_reqs.sh new file mode 100755 index 0000000..43c188c --- /dev/null +++ b/scripts/install_termux_reqs.sh @@ -0,0 +1,12 @@ +if ! echo "${PATH}" | grep -qi "com.termux"; then + echo "Not a termux Env, Skipping..." + exit +fi + +ub_core_req_url="https://github.com/thedragonsinn/ub-core/raw/main/requirements.txt" + +curl -fsSL ${ub_core_req_url} | grep -Ev "uvloop|psutil" | xargs pip install + +./scripts/install_ub_core.sh "--no-deps" + +grep -Ev "google-generativeai|pillow" req.txt | xargs -n 1 pip install \ No newline at end of file diff --git a/scripts/install_ub_core.sh b/scripts/install_ub_core.sh new file mode 100755 index 0000000..9de5e0c --- /dev/null +++ b/scripts/install_ub_core.sh @@ -0,0 +1,7 @@ +dual_mode_arg="" + +if [ ! -z "${USE_DUAL_BRANCH}" ]; then + dual_mode_arg="@dual_mode" +fi + +pip -q install --no-cache-dir --force-reinstall $1 "git+https://github.com/thedragonsinn/ub-core${dual_mode_arg}" \ No newline at end of file