From 7be856f82916b7e2ae8e326ba8a59f7e8e23c999 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sun, 29 May 2022 16:00:21 +0200 Subject: [PATCH 1/4] fix crontab --- docker/README.md | 4 ++-- docker/rootfs/etc/cron.d/{01-manga-dlp => 01_mangadlp} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename docker/rootfs/etc/cron.d/{01-manga-dlp => 01_mangadlp} (89%) diff --git a/docker/README.md b/docker/README.md index 27b11f7..2b75c93 100644 --- a/docker/README.md +++ b/docker/README.md @@ -49,12 +49,12 @@ To use your own schedule you need to mount (override) the default crontab or add ```yml # docker-compose.yml volumes: - - ./crontab:/etc/cron.d/01_manga-dlp # overwrites the default one + - ./crontab:/etc/cron.d/01_mangadlp # overwrites the default one - ./crontab2:/etc/cron.d/02_something # adds a new one ``` ```sh -docker run -v ./crontab:/etc/cron.d/01_manga-dlp # overwrites the default one +docker run -v ./crontab:/etc/cron.d/01_mangadlp # overwrites the default one docker run -v ./crontab2:/etc/cron.d/02_something # adds a new one ``` diff --git a/docker/rootfs/etc/cron.d/01-manga-dlp b/docker/rootfs/etc/cron.d/01_mangadlp similarity index 89% rename from docker/rootfs/etc/cron.d/01-manga-dlp rename to docker/rootfs/etc/cron.d/01_mangadlp index 3547e86..6225fb8 100644 --- a/docker/rootfs/etc/cron.d/01-manga-dlp +++ b/docker/rootfs/etc/cron.d/01_mangadlp @@ -2,4 +2,4 @@ # and get all (new) chapters of the mangas in # the file mangas.txt -0 3 * * * abc python3 /app/manga-dlp.py --read /app/mangas.txt -c all +0 3 * * * abc python3 /app/manga-dlp.py --read /app/mangas.txt -c all --wait 2 -- 2.45.2 From 781b25c2e87a51d0787e09ba0e44bd709100a5ba Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sun, 29 May 2022 19:11:38 +0200 Subject: [PATCH 2/4] fix docker container --- docker/Dockerfile.amd64 | 1 - docker/Dockerfile.arm64 | 1 - docker/README.md | 43 +++++++++++++++++----- docker/docker-compose.yml | 2 + docker/rootfs/app/schedules/daily | 7 ++++ docker/rootfs/etc/cont-init.d/80-fix-perms | 3 ++ docker/rootfs/etc/cron.d/01_mangadlp | 7 +++- 7 files changed, 51 insertions(+), 13 deletions(-) create mode 100755 docker/rootfs/app/schedules/daily diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 index 5e162ba..36571ce 100644 --- a/docker/Dockerfile.amd64 +++ b/docker/Dockerfile.amd64 @@ -28,7 +28,6 @@ RUN \ /var/tmp/* -# copy files to container # copy files to container COPY docker/rootfs / COPY mangadlp/ /app/mangadlp/ diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index dd205b0..6c59c0a 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -28,7 +28,6 @@ RUN \ /var/tmp/* -# copy files to container # copy files to container COPY docker/rootfs / COPY mangadlp/ /app/mangadlp/ diff --git a/docker/README.md b/docker/README.md index 2b75c93..e5ef57f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -33,6 +33,8 @@ docker run -e PUID= -e PGID= ## Run commands in container +> You don't need to use the full path of manga-dlp.py because `/app` already is the working directory + You can simply use the `docker exec` command to run the scripts like normal. ```sh @@ -41,21 +43,42 @@ docker exec python3 manga-dlp.py ## Run your own schedule -The default config runs manga-dlp.py once a day at 03:00 and fetches every chapter of the mangas listed in the file -mangas.txt in the root directory of this repo. +The default config runs `manga-dlp.py` once a day at 12:00 and fetches every chapter of the mangas listed in the file +`mangas.txt` in the root directory of this repo. -To use your own schedule you need to mount (override) the default crontab or add new ones to the cron directory. +#### The default options used are: + +```sh +--read mangas.txt +--chapters all +--path /app/downloads +--wait 2 +``` + +To use your own schedule you need to mount (override) the default schedule or add new ones to the crontab. + +> Don't forget to add the cron entries for every new schedule ```yml # docker-compose.yml volumes: - - ./crontab:/etc/cron.d/01_mangadlp # overwrites the default one - - ./crontab2:/etc/cron.d/02_something # adds a new one + - ./crontab:/etc/cron.d/01_mangadlp # overwrites the default crontab + - ./crontab2:/etc/cron.d/02_something # adds a new one crontab file + - ./schedule1:/app/schedules/daily # overwrites the default schedule + - ./schedule2:/app/schedules/weekly # adds a new schedule ``` ```sh -docker run -v ./crontab:/etc/cron.d/01_mangadlp # overwrites the default one -docker run -v ./crontab2:/etc/cron.d/02_something # adds a new one +docker run -v ./crontab:/etc/cron.d/01_mangadlp # overwrites the default crontab +docker run -v ./crontab2:/etc/cron.d/02_something # adds a new one crontab file +docker run -v ./schedule1:/app/schedules/daily # overwrites the default schedule +docker run -v ./schedule2:/app/schedules/weekly # adds a new schedule +``` + +#### The default crontab file: + +```sh +0 12 * * * root /app/schedule > /proc/1/fd/1 2>&1 ``` ## Add mangas to mangas.txt @@ -77,15 +100,15 @@ docker run -v ./mangas.txt:/app/mangas.txt Per default as in the script, it downloads everything to "downloads" in the scripts root directory. This data does not persist with container recreation, so you need to mount it. This is already done in the quick start section. If you want -to change the path of the host, simply change `./media/mangas/` to a path of your choice. +to change the path of the host, simply change `./downloads/` to a path of your choice. ```yml # docker-compose.yml volumes: - - ./media/mangas/:/app/downloads + - ./downloads/:/app/downloads ``` ```sh -docker run -v ./media/mangas/:/app/downloads +docker run -v ./downloads/:/app/downloads ``` diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d6144ed..1b47ccb 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,6 +12,8 @@ services: volumes: - ./downloads/:/app/downloads/ # default manga download directory - ./mangas.txt:/app/mangas.txt # default file for manga links to download + #- ./crontab:/etc/cron.d/mangadlp # path to default crontab + #- ./schedule:/app/schedules/daily # path to the default schedule which is run daily environment: - TZ=Europe/Zurich # - PUID= # custom userid - defaults to 4444 diff --git a/docker/rootfs/app/schedules/daily b/docker/rootfs/app/schedules/daily new file mode 100755 index 0000000..d1f0620 --- /dev/null +++ b/docker/rootfs/app/schedules/daily @@ -0,0 +1,7 @@ +#!/bin/bash + +exec s6-setuidgid abc python3 /app/manga-dlp.py \ + --path /app/downloads \ + --read /app/mangas.txt \ + --chapters all \ + --wait 2 diff --git a/docker/rootfs/etc/cont-init.d/80-fix-perms b/docker/rootfs/etc/cont-init.d/80-fix-perms index 1ec425d..bddecbc 100644 --- a/docker/rootfs/etc/cont-init.d/80-fix-perms +++ b/docker/rootfs/etc/cont-init.d/80-fix-perms @@ -10,3 +10,6 @@ find '/app' -type 'f' \( -not -perm 664 -and -not -path '/app/downloads*' \) -ex find '/app' \( -not -user abc -and -not -path '/app/downloads*' \) -exec chown abc '{}' \+ find '/app' \( -not -group abc -and -not -path '/app/downloads*' \) -exec chown :abc '{}' \+ + +# fix schedules +chmod -R +x /app/schedules diff --git a/docker/rootfs/etc/cron.d/01_mangadlp b/docker/rootfs/etc/cron.d/01_mangadlp index 6225fb8..9b34dfb 100644 --- a/docker/rootfs/etc/cron.d/01_mangadlp +++ b/docker/rootfs/etc/cron.d/01_mangadlp @@ -1,5 +1,10 @@ +SHELL=/bin/bash +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + # default crontab to run manga-dlp once a day # and get all (new) chapters of the mangas in # the file mangas.txt +# "/proc/1/fd/1 2>&1" is to show the logs in the container + +0 12 * * * root /app/schedule > /proc/1/fd/1 2>&1 -0 3 * * * abc python3 /app/manga-dlp.py --read /app/mangas.txt -c all --wait 2 -- 2.45.2 From f94c11b9334d2559764d2f10fde7939076208e67 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sun, 29 May 2022 20:41:10 +0200 Subject: [PATCH 3/4] change setuidgid from schedule to cron --- docker/README.md | 32 +++++++++++++------ docker/rootfs/app/schedules/daily | 2 +- .../etc/cron.d/{01_mangadlp => mangadlp} | 3 +- 3 files changed, 25 insertions(+), 12 deletions(-) rename docker/rootfs/etc/cron.d/{01_mangadlp => mangadlp} (67%) diff --git a/docker/README.md b/docker/README.md index e5ef57f..d4eb656 100644 --- a/docker/README.md +++ b/docker/README.md @@ -46,13 +46,16 @@ docker exec python3 manga-dlp.py The default config runs `manga-dlp.py` once a day at 12:00 and fetches every chapter of the mangas listed in the file `mangas.txt` in the root directory of this repo. -#### The default options used are: +#### The default schedule: ```sh ---read mangas.txt ---chapters all ---path /app/downloads ---wait 2 +#!/bin/bash + +python3 /app/manga-dlp.py \ + --path /app/downloads \ + --read /app/mangas.txt \ + --chapters all \ + --wait 2 ``` To use your own schedule you need to mount (override) the default schedule or add new ones to the crontab. @@ -62,15 +65,15 @@ To use your own schedule you need to mount (override) the default schedule or ad ```yml # docker-compose.yml volumes: - - ./crontab:/etc/cron.d/01_mangadlp # overwrites the default crontab - - ./crontab2:/etc/cron.d/02_something # adds a new one crontab file + - ./crontab:/etc/cron.d/mangadlp # overwrites the default crontab + - ./crontab2:/etc/cron.d/something # adds a new one crontab file - ./schedule1:/app/schedules/daily # overwrites the default schedule - ./schedule2:/app/schedules/weekly # adds a new schedule ``` ```sh -docker run -v ./crontab:/etc/cron.d/01_mangadlp # overwrites the default crontab -docker run -v ./crontab2:/etc/cron.d/02_something # adds a new one crontab file +docker run -v ./crontab:/etc/cron.d/mangadlp # overwrites the default crontab +docker run -v ./crontab2:/etc/cron.d/something # adds a new one crontab file docker run -v ./schedule1:/app/schedules/daily # overwrites the default schedule docker run -v ./schedule2:/app/schedules/weekly # adds a new schedule ``` @@ -78,7 +81,16 @@ docker run -v ./schedule2:/app/schedules/weekly # adds a new schedule #### The default crontab file: ```sh -0 12 * * * root /app/schedule > /proc/1/fd/1 2>&1 +SHELL=/bin/bash +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +# default crontab to run manga-dlp once a day +# and get all (new) chapters of the mangas in +# the file mangas.txt +# "/proc/1/fd/1 2>&1" is to show the logs in the container +# "s6-setuidgid abc" is used to set the permissions + +0 12 * * * root s6-setuidgid abc /app/schedules/daily > /proc/1/fd/1 2>&1 ``` ## Add mangas to mangas.txt diff --git a/docker/rootfs/app/schedules/daily b/docker/rootfs/app/schedules/daily index d1f0620..d1d9d1f 100755 --- a/docker/rootfs/app/schedules/daily +++ b/docker/rootfs/app/schedules/daily @@ -1,6 +1,6 @@ #!/bin/bash -exec s6-setuidgid abc python3 /app/manga-dlp.py \ +python3 /app/manga-dlp.py \ --path /app/downloads \ --read /app/mangas.txt \ --chapters all \ diff --git a/docker/rootfs/etc/cron.d/01_mangadlp b/docker/rootfs/etc/cron.d/mangadlp similarity index 67% rename from docker/rootfs/etc/cron.d/01_mangadlp rename to docker/rootfs/etc/cron.d/mangadlp index 9b34dfb..3db1d4d 100644 --- a/docker/rootfs/etc/cron.d/01_mangadlp +++ b/docker/rootfs/etc/cron.d/mangadlp @@ -5,6 +5,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # and get all (new) chapters of the mangas in # the file mangas.txt # "/proc/1/fd/1 2>&1" is to show the logs in the container +# "s6-setuidgid abc" is used to set the permissions -0 12 * * * root /app/schedule > /proc/1/fd/1 2>&1 +0 12 * * * root s6-setuidgid abc /app/schedules/daily > /proc/1/fd/1 2>&1 -- 2.45.2 From c52099220fc97e249b1aa0f7cbdd3671e697a26e Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Sun, 29 May 2022 20:43:58 +0200 Subject: [PATCH 4/4] changelog + push version --- CHANGELOG.md | 11 +++++++++++ docker/Dockerfile.amd64 | 2 +- docker/Dockerfile.arm64 | 2 +- manga-dlp.py | 2 +- mangadlp/input.py | 2 +- setup.py | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55a83e3..7901524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add support for more sites +## [2.1.4] - 2022-05-29 + +### Fixed + +- Docker container now works again +- Fixed cron in docker container + +### Changed + +- Docker container scheduling is now more practical + ## [2.1.3] - 2022-05-29 ### Fixed diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 index 36571ce..23068c9 100644 --- a/docker/Dockerfile.amd64 +++ b/docker/Dockerfile.amd64 @@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="Ivan Schaller" # manga-dlp version -ENV MDLP_VERSION=2.1.3 +ENV MDLP_VERSION=2.1.4 # install packages RUN \ diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 6c59c0a..a1c5510 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="Ivan Schaller" # manga-dlp version -ENV MDLP_VERSION=2.1.3 +ENV MDLP_VERSION=2.1.4 # install packages RUN \ diff --git a/manga-dlp.py b/manga-dlp.py index 40715cf..75dfe24 100644 --- a/manga-dlp.py +++ b/manga-dlp.py @@ -3,7 +3,7 @@ import sys from mangadlp.input import get_args -mangadlp_version = "2.1.3" +mangadlp_version = "2.1.4" def get_input(): diff --git a/mangadlp/input.py b/mangadlp/input.py index a18e142..4ae6871 100644 --- a/mangadlp/input.py +++ b/mangadlp/input.py @@ -4,7 +4,7 @@ from pathlib import Path import mangadlp.app as app -mangadlp_version = "2.1.3" +mangadlp_version = "2.1.4" def check_args(args): diff --git a/setup.py b/setup.py index 1877374..151d055 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = readme.read_text() setuptools.setup( name="manga-dlp", - version="2.1.3", + version="2.1.4", author="Ivan Schaller", author_email="ivan@schaller.sh", description="A cli manga downloader", -- 2.45.2