From 2075780a93f82c11536838cc0feb8aabcd5d3516 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 13 Jun 2019 13:22:36 +0000 Subject: [PATCH] improve android script --- README.md | 1 - scripts/copyparty-android.sh | 34 ++++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9a584350..2e578f78 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ roughly sorted by priority * permissions break for `ed` on `-v /home/ed/vfs:moji:r -v /home/ed/inc:inc:r:aed` * http error handling (conn.status or handler-retval) * look into android thumbnail cache file format -* run-script for android * last-modified header * support pillow-simd * figure out the deal with pixel3a not being connectable as hotspot diff --git a/scripts/copyparty-android.sh b/scripts/copyparty-android.sh index 4da14955..90e10129 100755 --- a/scripts/copyparty-android.sh +++ b/scripts/copyparty-android.sh @@ -1,10 +1,11 @@ #!/bin/bash set -e -msg() { printf '\n\033[1;30m>\033[0;33m>\033[1m>\033[0m %s\n' "$1" >&2; } +_msg() { printf "$2"'\033[1;30m>\033[0;33m>\033[1m>\033[0m %s\n' "$1" >&2; } +imsg() { _msg "$1" ''; } +msg() { _msg "$1" \\n; } mkdir -p ~/src -cd ~/src ## ## helper which installs termux packages @@ -26,16 +27,17 @@ addpkg() { ## ## ensure git and copyparty is available -[ -e copyparty/.ok ] || { +[ -e ~/src/copyparty/.ok ] || { command -v git >/dev/null || addpkg git - # in case of partial clone - rm -rf copyparty - msg "downloading copyparty from github" - git clone https://github.com/9001/copyparty - touch copyparty/.ok + ( + cd ~/src + rm -rf copyparty + git clone https://github.com/9001/copyparty + touch copyparty/.ok + ) } ## @@ -47,9 +49,8 @@ command -v python3 >/dev/null || ## ## ensure virtualenv and dependencies are available -cd ~/src/copyparty - -[ -e .env/.ok ] || { +[ -e ~/src/copyparty/.env/.ok ] || { ( + cd ~/src/copyparty rm -rf .env msg "creating python3 virtualenv" @@ -60,7 +61,8 @@ cd ~/src/copyparty pip install jinja2 deactivate -} + touch .env/.ok +) } ## ## add copyparty alias to bashrc @@ -73,9 +75,9 @@ grep -qE '^alias copyparty=' ~/.bashrc 2>/dev/null || { ## ## start copyparty -msg "activating virtualenv" -. .env/bin/activate +imsg "activating virtualenv" +. ~/src/copyparty/.env/bin/activate -msg "starting copyparty" -python3 -m copyparty "$@" +imsg "starting copyparty" +PYTHONPATH=~/src/copyparty python3 -m copyparty "$@"