From f3f7024401be23595a843a2b66ee1556bbc2959a Mon Sep 17 00:00:00 2001 From: kannibalox Date: Sat, 18 Mar 2023 12:10:40 -0400 Subject: [PATCH] Fix up archiver.sh and add tinycron --- Dockerfile | 1 + resources/archiver.sh | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17a712d..e4a9518 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,5 +34,6 @@ ENV VIRTUAL_ENV="/venv" RUN bash -c 'echo -e "[Main]\nbaseURL=https://passthepopcorn.me/\ndownloadDirectory=/data/" > ~/.ptpapi.conf' +RUN wget https://github.com/bcicen/tinycron/releases/download/v0.4/tinycron-0.4-linux-amd64 > /usr/local/bin/tinycron && chmod +x /usr/local/bin/tinycron COPY ./resources/archiver.sh /usr/local/bin/ COPY --from=builder /venv /venv diff --git a/resources/archiver.sh b/resources/archiver.sh index fe12b57..27e4651 100755 --- a/resources/archiver.sh +++ b/resources/archiver.sh @@ -1,11 +1,22 @@ #!/bin/bash -set -eu -install_file="/data/archiver.py" +set -u +archive_script="/data/archiver.py" if [[ ! -d "/data/" ]]; then mkdir /data/ fi -if [[ ! -e "$install_file" ]]; then - curl -v -H "ApiUser: ${PTPAPI_APIUSER}" -H "ApiKey: ${PTPAPI_APIKEY}" "https://passthepopcorn.me/archive.php?action=script" \ - > "$install_file" +cd /data/ || exit 1 # Exit if /data/ isn't available +if [[ ! -e "$archive_script" ]]; then + echo "archiver.py does not exist, installing" + wget --header "ApiUser: ${PTPAPI_APIUSER}" --header "ApiKey: ${PTPAPI_APIKEY}" \ + "https://passthepopcorn.me/archive.php?action=script" \ + -O "$archive_script" + if [ $? -ne 0 ] ; then + echo "Could not download script" + if [[ -e "$archive_script" ]]; then + cat "$archive_script" + rm -f "$archive_script" + fi + exit + fi fi -/venv/bin/python ${install_file} "$@" --config /data/config.ptp +/venv/bin/python "${archive_script}" "$@"