Skip to content

Commit

Permalink
Fix up archiver.sh and add tinycron
Browse files Browse the repository at this point in the history
  • Loading branch information
kannibalox committed Mar 18, 2023
1 parent 198bf8c commit f3f7024
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 17 additions & 6 deletions resources/archiver.sh
Original file line number Diff line number Diff line change
@@ -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}" "$@"

0 comments on commit f3f7024

Please sign in to comment.