Files
copyparty/scripts/copyparty-android.sh

63 lines
1.1 KiB
Bash
Raw Normal View History

2019-06-13 11:39:55 +00:00
#!/bin/bash
set -e
2019-06-13 13:22:36 +00:00
_msg() { printf "$2"'\033[1;30m>\033[0;33m>\033[1m>\033[0m %s\n' "$1" >&2; }
imsg() { _msg "$1" ''; }
msg() { _msg "$1" \\n; }
2019-06-13 11:39:55 +00:00
##
## helper which installs termux packages
termux_upd=y
addpkg() {
t0=$(date +%s -r ~/../usr/var/cache/apt/pkgcache.bin 2>/dev/null || echo 0)
t1=$(date +%s)
[ $((t1-t0)) -gt 600 ] && {
msg "upgrading termux packages"
apt update
apt full-upgrade -y
}
msg "installing $1 from termux repos"
apt install -y $1
}
##
## ensure python is available
command -v python3 >/dev/null ||
addpkg python
##
## ensure virtualenv and dependencies are available
2020-05-06 00:11:36 +02:00
ve=$HOME/ve.copyparty
[ -e $ve/.ok ] || (
rm -rf $ve
2019-06-13 11:39:55 +00:00
msg "creating python3 virtualenv"
2020-05-06 00:11:36 +02:00
python3 -m venv $ve
2019-06-13 11:39:55 +00:00
2020-05-06 00:11:36 +02:00
msg "installing copyparty"
. $ve/bin/activate
pip install copyparty
2019-06-13 11:39:55 +00:00
deactivate
2020-05-06 00:11:36 +02:00
touch $ve/.ok
)
2019-06-13 11:39:55 +00:00
##
## add copyparty alias to bashrc
grep -qE '^alias copyparty=' ~/.bashrc 2>/dev/null || {
msg "adding alias to bashrc"
echo "alias copyparty='$HOME/copyparty-android.sh'" >> ~/.bashrc
}
##
## start copyparty
2019-06-13 13:22:36 +00:00
imsg "starting copyparty"
2020-05-06 00:11:36 +02:00
$ve/bin/python -m copyparty "$@"