Propably working Dockerfile.
This commit is contained in:
parent
62562b6060
commit
1026bd59d4
@ -1,24 +0,0 @@
|
|||||||
name: Try building docker image
|
|
||||||
run-name: Try building docker image
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
smth:
|
|
||||||
name: idk something
|
|
||||||
runs-on: [ubuntu-latest, aarch64]
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: somename
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@main
|
|
||||||
- name: Build docker image
|
|
||||||
run: docker build -t $IMAGE_NAME:latest ./docker/
|
|
||||||
# branch v3
|
|
||||||
# uses: actions/checkout@v3
|
|
||||||
# - name: Build docker images
|
|
||||||
# run: docker compose build
|
|
||||||
# - name: Start
|
|
||||||
# run: docker compose run
|
|
@ -1,3 +1,3 @@
|
|||||||
# A list of EU and American Debian mirror URLs
|
# A list of EU and American Debian mirror URLs
|
||||||
|
|
||||||
I'll propably set some scraping script up that would update that list like once per day.
|
It scrapes URL's of debian mirrors for later use in opnsense as an alias that ony allows access to debian repositories
|
3
code/.gitignore
vendored
3
code/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
|
test
|
52
code/test.py
52
code/test.py
@ -1,52 +0,0 @@
|
|||||||
from typing import Optional, Annotated
|
|
||||||
import dns, dns.resolver, socket
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
result = dns.resolver.resolve(inpDomainNameOrSomething, 'A')
|
|
||||||
# result = dns.resolver.resolve_name(inpDomainNameOrSomething)
|
|
||||||
for i, something in enumerate(result):
|
|
||||||
outDict[i] = something.to_text()
|
|
||||||
# i += 1
|
|
||||||
|
|
||||||
return outDict
|
|
||||||
|
|
||||||
|
|
||||||
# print(socket.getaddrinfo(url, "443"))
|
|
||||||
|
|
||||||
url = "https://data.fubukus.net/assets/"
|
|
||||||
# url = "http://ftp.eq.uc.pt/software/Linux/debian/"
|
|
||||||
|
|
||||||
if "https://" in url:
|
|
||||||
url = url[8:]
|
|
||||||
elif "http://" in url:
|
|
||||||
url = url[7:]
|
|
||||||
i = 0
|
|
||||||
for char in url:
|
|
||||||
# print(char)
|
|
||||||
i += 1
|
|
||||||
if char == "/":
|
|
||||||
url = url[:i]
|
|
||||||
# i = 0
|
|
||||||
|
|
||||||
# print("skibidi")
|
|
||||||
if char == "/":
|
|
||||||
url = url[:-1]
|
|
||||||
|
|
||||||
print(url)
|
|
||||||
# print(ermWhatATheIpFromDomainYaCrazy(url))
|
|
3
docker/.gitignore
vendored
Normal file
3
docker/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
repo
|
||||||
|
__pycache__
|
||||||
|
.env
|
@ -7,21 +7,22 @@ RUN apk update && \
|
|||||||
apk add python3 py3-pip git
|
apk add python3 py3-pip git
|
||||||
# inotify-tools
|
# inotify-tools
|
||||||
|
|
||||||
RUN mkdir /etc/debmirror
|
RUN mkdir /etc/debmirror && \
|
||||||
|
touch /etc/debmirror/MirrorListV6 && \
|
||||||
|
touch /etc/debmirror/MirrorListV4
|
||||||
WORKDIR /etc/debmirror/
|
WORKDIR /etc/debmirror/
|
||||||
|
|
||||||
COPY ./mainDocker.py /etc/debmirror/
|
COPY mainDocker.py /etc/debmirror/
|
||||||
COPY ./requirements.txt /etc/debmirror/
|
COPY whatDomain.py /etc/debmirror/
|
||||||
|
COPY requirements.txt /etc/debmirror/
|
||||||
|
|
||||||
RUN python3 -m venv venv && \
|
RUN python3 -m venv venv && \
|
||||||
venv/bin/python3 -m pip install --upgrade pip && \
|
venv/bin/python3 -m pip install --upgrade pip && \
|
||||||
venv/bin/pip3 install -r requirements.txt
|
venv/bin/pip3 install -r requirements.txt
|
||||||
|
|
||||||
COPY ./cron-jobs /etc/crontabs/
|
COPY cron-jobs /etc/crontabs/
|
||||||
COPY ./gitPush.sh /etc/crontabs/
|
COPY gitPush.sh /etc/crontabs/
|
||||||
|
|
||||||
RUN chmod +x /etc/crontabs/gitPush.sh
|
RUN chmod +x /etc/crontabs/gitPush.sh
|
||||||
|
|
||||||
RUN git clone https://tea.shupogaki.org/YuruC3/Debain-repos
|
|
||||||
|
|
||||||
CMD ["/usr/sbin/crond"]
|
CMD ["/usr/sbin/crond"]
|
||||||
|
@ -2,5 +2,4 @@
|
|||||||
25 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
|
25 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
|
||||||
|
|
||||||
# git push
|
# git push
|
||||||
|
|
||||||
30 19 * * * /bin/sh /etc/debmirror/gitPush.sh
|
30 19 * * * /bin/sh /etc/debmirror/gitPush.sh
|
@ -1,12 +1,34 @@
|
|||||||
#!/bin/sh
|
#!/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
|
|
||||||
|
@ -4,7 +4,7 @@ from whatDomain import *
|
|||||||
|
|
||||||
|
|
||||||
if os.environ["DEBMIRRORURL"]:
|
if os.environ["DEBMIRRORURL"]:
|
||||||
DEBMIRRORURL = str(os.environ["DEBMIRRORURL"])
|
DEBMIRRORURL = os.environ["DEBMIRRORURL"]
|
||||||
else:
|
else:
|
||||||
DEBMIRRORURL = "https://www.debian.org/mirror/list"
|
DEBMIRRORURL = "https://www.debian.org/mirror/list"
|
||||||
|
|
||||||
@ -144,4 +144,5 @@ def LeJob():
|
|||||||
fW.write(ip + "/128" + "\n")
|
fW.write(ip + "/128" + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LeJob()
|
LeJob()
|
||||||
|
87
docker/whatDomain.py
Normal file
87
docker/whatDomain.py
Normal 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"))
|
Loading…
x
Reference in New Issue
Block a user