Propably working Dockerfile.

This commit is contained in:
YuruC3
2025-05-11 15:08:26 +02:00
parent 62562b6060
commit 1026bd59d4
11 changed files with 134 additions and 97 deletions

3
docker/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
repo
__pycache__
.env

View File

@@ -7,21 +7,22 @@ RUN apk update && \
apk add python3 py3-pip git
# inotify-tools
RUN mkdir /etc/debmirror
RUN mkdir /etc/debmirror && \
touch /etc/debmirror/MirrorListV6 && \
touch /etc/debmirror/MirrorListV4
WORKDIR /etc/debmirror/
COPY ./mainDocker.py /etc/debmirror/
COPY ./requirements.txt /etc/debmirror/
COPY mainDocker.py /etc/debmirror/
COPY whatDomain.py /etc/debmirror/
COPY requirements.txt /etc/debmirror/
RUN python3 -m venv venv && \
venv/bin/python3 -m pip install --upgrade pip && \
venv/bin/pip3 install -r requirements.txt
COPY ./cron-jobs /etc/crontabs/
COPY ./gitPush.sh /etc/crontabs/
COPY cron-jobs /etc/crontabs/
COPY gitPush.sh /etc/crontabs/
RUN chmod +x /etc/crontabs/gitPush.sh
RUN git clone https://tea.shupogaki.org/YuruC3/Debain-repos
CMD ["/usr/sbin/crond"]

View File

@@ -2,5 +2,4 @@
25 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
# git push
30 19 * * * /bin/sh /etc/debmirror/gitPush.sh

View File

@@ -1,12 +1,34 @@
#!/bin/sh
GITPATH="/etc/debmirror/"
set -e
# https://github.com/mujtaba1747/git-autocommit/tree/master
WORKPTH="/etc/debmirror/"
REPO_DIR="$WORKPTH/Debain-repos"
REPO_URL="https://$GITEA_TOKEN@tea.shupogaki.org/YuruC3/Debain-repos.git"
# Clone repo only if it doesn't already exist
if [ ! -d "$REPO_DIR/.git" ]; then
echo "[$(date)] Cloning repository..."
git clone "$REPO_URL" "$REPO_DIR"
fi
cd "$REPO_DIR"
git config user.name "UpdateBot"
git config user.email "UpdateBot@localhost.local"
# pull changes
git pull
# check if modified
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to commit."
# if yes, push
else
git add MirrorsV4 MirrorsV6
git commit -m "Auto-update mirror list on $(date -Iseconds)"
git push
echo "Changes pushed successfully."
fi
inotifywait --recursive -qq -e modify,close_write $GITPATH
cd $GITPATH &> /dev/null
git pull &> /dev/null
git add --all &> /dev/null
now=$(date) &> /dev/null
git commit -m "Auto-Commit at: $now" &> /dev/null
git push -u origin main &> /dev/null

View File

@@ -4,7 +4,7 @@ from whatDomain import *
if os.environ["DEBMIRRORURL"]:
DEBMIRRORURL = str(os.environ["DEBMIRRORURL"])
DEBMIRRORURL = os.environ["DEBMIRRORURL"]
else:
DEBMIRRORURL = "https://www.debian.org/mirror/list"
@@ -144,4 +144,5 @@ def LeJob():
fW.write(ip + "/128" + "\n")
LeJob()

87
docker/whatDomain.py Normal file
View File

@@ -0,0 +1,87 @@
#from nslookup import Nslookup
from typing import Optional, Annotated
import dns, dns.resolver
# https://www.codeunderscored.com/nslookup-python/
def ermWhatATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Domain name to lookup IP for"]):
#dns_query = Nslookup()
"""
Tells you what IPv4 address/es a domain point to.
Returns:
dict: A dictionary with IP addresses associated with that domain.
"""
# i = 0
outDict = {}
#result = dns_query.dns_lookup("example.com")
#result = Nslookup.dns_lookup(inpDomainNameOrSomething)
try:
result = dns.resolver.resolve(inpDomainNameOrSomething, 'A')
except dns.resolver.NoAnswer:
return -1
for i, something in enumerate(result):
outDict[i] = something.to_text()
# i += 1
return outDict
def ermWhatAAAATheIpFromDomainYaCrazy(inpDomainNameOrSomething: Annotated[str, "Domain name to lookup IP for"]):
#dns_query = Nslookup()
"""
Tells you what IPv6 address/es a domain point to.
Returns:
dict: A dictionary with IP addresses associated with that domain.
"""
# i = 0
outDict = {}
#result = dns_query.dns_lookup("example.com")
#result = Nslookup.dns_lookup(inpDomainNameOrSomething)
try:
result = dns.resolver.resolve(inpDomainNameOrSomething, 'AAAA')
except dns.resolver.NoAnswer:
return -1
for i, something in enumerate(result):
outDict[i] = something.to_text()
# i += 1
return outDict
def ermWhatPTRTheIpFromDomainYaCrazy(inpIpAddressOrSomething: Annotated[str, "IP address to lookup domain for"]):
#dns_query = Nslookup()
"""
Tells you what IPv6 address/es a domain point to.
Returns:
dict: A dictionary with IP addresses associated with that domain.
"""
whatToCheck = inpIpAddressOrSomething + ".in-addr.arpa"
# i = 0
outDict = {}
#result = dns_query.dns_lookup("example.com")
#result = Nslookup.dns_lookup(inpDomainNameOrSomething)
try:
result = dns.resolver.resolve(whatToCheck, 'PTR')
except dns.resolver.NoAnswer:
return -1
for i, something in enumerate(result):
outDict[i] = something.to_text()
# i += 1
return outDict
#print(ermWhatATheIpFromDomainYaCrazy("fubukus.net"))
#print(ermWhatAAAATheIpFromDomainYaCrazy("fubukus.net"))
#print(ermWhatPTRTheIpFromDomainYaCrazy("192.168.1.226"))