Skip to content

Commit

Permalink
Merge pull request #92 from MainKronos/dev
Browse files Browse the repository at this point in the history
1.9.2
  • Loading branch information
MainKronos authored Feb 17, 2023
2 parents c8f396f + 51a25ce commit d150815
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 41 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: set_version=${{ env.RELEASE_VERSION }}

- name: Image latest digest
run: echo ${{ steps.docker_build_latest.outputs.digest }}
Expand Down
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ docker run -d \
-v /path/to/downloads:/downloads \
-v /path/to/connections:/script/connections \
-p {port}:5000 \
--env SONARR_URL='http://{url}:{port}' \
--env API_KEY='1234567890abcdefghijklmn' \
--env CHAT_ID=123456789 \
--env BOT_TOKEN='123456789:ABCDEFGHIJKLM-abc_AbCdEfGhI12345678' \
--env SONARR_URL=http://{url}:{port} \
--env API_KEY=1234567890abcdefghijklmn \
--env TZ=Europe/Rome \
mainkronos/anime_downloader
```
Expand Down
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get -y install ffmpeg; \
apt-get -y install rtmpdump; \
apt-get -y install tzdata; \
apt-get -y install build-essential; \
apt-get -y install locales && locale-gen it_IT.UTF-8; \
apt-get clean; \
apt-get autoclean; \
Expand All @@ -37,21 +38,26 @@ COPY config/ /script/
RUN chmod 777 /downloads -R
RUN chmod 777 /script -R

RUN gcc /script/start.c -o /start.bin
RUN rm /script/start.c
RUN chown root:root /start.bin
RUN chmod 6751 /start.bin

RUN sed -i -e 's/# it_IT.UTF-8 UTF-8/it_IT.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=it_IT.UTF-8

ENV WERKZEUG_RUN_MAIN true
ENV FLASK_ENV production
ENV FLASK_DEBUG production
ENV PIP_ROOT_USER_ACTION ignore

# USER dockeruser
ENV USER_NAME dockeruser

ENV VERSION "1.9.1"
ARG set_version="dev"
ENV VERSION=$set_version

EXPOSE 5000

VOLUME [ "/downloads", "/script/json", "/script/connections" ]

CMD ["/script/start.sh"]
CMD ["/start.bin"]
4 changes: 3 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import threading
import requests
import sys


from other.constants import SONARR_URL, API_KEY, VERSION
Expand Down Expand Up @@ -62,7 +63,8 @@ def refresh(self, silent=False):


def server():
app.run(debug=False, host='0.0.0.0', use_reloader=False)
sys.modules['flask.cli'].show_server_banner = lambda *x: None
app.run(debug=False, host='0.0.0.0', use_reloader=False)

if __name__ == '__main__':
main()
Expand Down
89 changes: 89 additions & 0 deletions config/start.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <dirent.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/types.h>

int main(int argc, char *argv[])
{
int status; /* Stato di uscita processo figlio */
struct passwd* res; /* Risultato valore getpwnam */
DIR* dir; /* Cartella */
struct dirent* dir_inf;

int dbg = 0;

char* PUID = getenv("PUID");
if(!PUID) PUID = "1000";
char* PGID = getenv("PGID");
if(!PGID) PGID = "1000";
char* USER_NAME = getenv("USER_NAME");

if(fork()){
wait(&status);
if(fork()){
wait(&status);

res = getpwnam(USER_NAME);

printf(
"\n\n-------------------------------------\n"
"GID/UID\n"
"-------------------------------------\n"
"User uid:\t%d\n"
"User gid:\t%d\n"
"-------------------------------------\n\n\n",
res->pw_uid, res->pw_gid
);
if(fork()){
wait(&status);
if(fork()){
wait(&status);
if(fork()){
wait(&status);
if(fork()){
wait(&status);
if(fork()){
wait(&status);
if(fork()){
wait(&status);
if(fork()){
wait(&status);

chdir("/script");
setuid(atoi(PUID));

return system("python3 -u /script/main.py");
} else {
char* tmp; /* buffer */
dir = opendir("/script/connections");
if(!dir) exit(0);

while(1){
dir_inf = readdir(dir);
if(!dir_inf) exit(0);

if((tmp = strrchr(dir_inf->d_name, '.'))){
if(strcmp(".sh", tmp) == 0) break;
}
}
closedir(dir);

execlp(NULL, "sed", "-i", "-e", "'s/\\r$//'", "/script/connections/*.sh", NULL);
}
} else execlp(NULL, "pip3", "install", "--upgrade", "--no-cache-dir", "--disable-pip-version-check", "--quiet", "animeworld", NULL);
} else execlp(NULL, "chmod", "777", "/script", "-R", NULL);
} else execlp(NULL, "chgrp", USER_NAME, "/script", "-R", NULL);
} else execlp(NULL, "chown", USER_NAME, "/script", "-R", NULL);
} else execlp(NULL, "touch", "/script/json/table.json", NULL);
} else execlp(NULL, "touch", "/script/json/settings.json", NULL);
} else execlp(NULL, "groupmod", "-o", "-g", PGID, USER_NAME, NULL);
} else execlp(NULL, "usermod", "-o", "-u", PUID, USER_NAME, NULL);

fprintf(stderr, "ERROR %d: %s", dbg, strerror(errno));
exit(EXIT_FAILURE);
}
31 changes: 0 additions & 31 deletions config/start.sh

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ animeworld>=1.4.22
schedule>=0.6.0
flask
flask_socketio
werkzeug==2.0.0
werkzeug==2.2.3

0 comments on commit d150815

Please sign in to comment.