From e02690148b9a43b2cb64226b834f6eeedc91b468 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Wed, 8 Jan 2025 13:31:00 +0200 Subject: [PATCH] syncplay wrapper: only work more once a day --- bash/usr-local-bin/syncplay | 48 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/bash/usr-local-bin/syncplay b/bash/usr-local-bin/syncplay index 29bc153..c8b3989 100755 --- a/bash/usr-local-bin/syncplay +++ b/bash/usr-local-bin/syncplay @@ -4,32 +4,38 @@ set -x -# If syncplay doesn't exist, get it -if [ ! -d "$HOME/src/github.com/syncplay" ]; then - mkdir -p ~/src/github.com/syncplay/syncplay - git clone https://github.com/syncplay/syncplay.git ~/src/github.com/syncplay/syncplay || exit - mkdir -p ~/src/github.com/syncplay/syncplay/venv +if [ -f "/tmp/syncplay.$(id -u).$(date -I)" ]; then + echo "Syncplay has been touched today" else - # In this case Syncplay does exist, let's upgrade it + # If syncplay doesn't exist, get it + if [ ! -d "$HOME/src/github.com/syncplay" ]; then + mkdir -p ~/src/github.com/syncplay/syncplay + git clone https://github.com/syncplay/syncplay.git ~/src/github.com/syncplay/syncplay || exit + mkdir -p ~/src/github.com/syncplay/syncplay/venv + else + # In this case Syncplay does exist, let's upgrade it + cd ~/src/github.com/syncplay/syncplay || exit + git pull || exit + mkdir -p venv + fi + + # Let's ensure we have venv setup. Spellcheck complains if I won't || exit + # every cd, which I understand to mean in failure case terminate the script. cd ~/src/github.com/syncplay/syncplay || exit - git pull || exit - mkdir -p venv + python3 -m venv venv || exit + # Switch to the venv + . ~/src/github.com/syncplay/syncplay/venv/bin/activate + + # pip will complain if it has updates available, so it must be updated + # and the syncplay requirements should be up-to-date too. + pip3 install pip --upgrade + pip3 install -r requirements.txt --upgrade + pip3 install -r requirements_gui.txt --upgrade + touch /tmp/syncplay.$(id -u).$(date -I) fi -# Let's ensure we have venv setup. Spellcheck complains if I won't || exit -# every cd, which I understand to mean in failure case terminate the script. -cd ~/src/github.com/syncplay/syncplay || exit -python3 -m venv venv || exit -# Switch to the venv +# finally launch the syncplay with any flags specified . ~/src/github.com/syncplay/syncplay/venv/bin/activate - -# pip will complain if it has updates available, so it must be updated -# and the syncplay requirements should be up-to-date too. -pip3 install pip --upgrade -pip3 install -r requirements.txt --upgrade -pip3 install -r requirements_gui.txt --upgrade - -# finally launch the syncplay server with any flags specified ~/src/github.com/syncplay/syncplay/syncplayClient.py "$@" # my syncplay launcher says this is a terminal app, so in case something goes # wrong, let it stay open for a moment for me to see what.