forked from public/mirror-checker
Created Kernel mirror status checker
parent
708579e0db
commit
4a8a7918b4
17
main.py
17
main.py
|
@ -18,6 +18,11 @@ def get_debian_dt(trace_file_url):
|
|||
time_str = response_text.split('\n')[0]
|
||||
return datetime.strptime(time_str, "%a %b %d %H:%M:%S UTC %Y")
|
||||
|
||||
def get_kernel_line_count(checksum_file_url):
|
||||
"""Get Kernel line count of checksum file"""
|
||||
response_text = requests.get(checksum_file_url).text
|
||||
return len(response_text.split('\n'))
|
||||
|
||||
def get_openbsd_sec(timestamp_file_url):
|
||||
"""Get OpenBSD seconds since the Epoch from timestamp file"""
|
||||
sec_str = requests.get(timestamp_file_url).text
|
||||
|
@ -50,6 +55,18 @@ if __name__ == "__main__":
|
|||
except requests.exceptions.RequestException as err:
|
||||
print(ERROR.format("Debian", err))
|
||||
|
||||
# Kernel
|
||||
try:
|
||||
official_line_count = get_kernel_line_count(
|
||||
"https://mirrors.edge.kernel.org/pub/linux/kernel/next/sha256sums.asc")
|
||||
csc_line_count = get_kernel_line_count(
|
||||
f"{CSC_MIRROR}kernel.org/linux/kernel/next/sha256sums.asc")
|
||||
# A new update on a certain day adds 2 new lines
|
||||
OUTPUT = SUCCESS if official_line_count <= csc_line_count + 2 else FAILURE
|
||||
print(OUTPUT.format("Kernel"))
|
||||
except requests.exceptions.RequestException as err:
|
||||
print(ERROR.format("Kernel", err))
|
||||
|
||||
# OpenBSD
|
||||
try:
|
||||
official_sec = get_openbsd_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp")
|
||||
|
|
Loading…
Reference in New Issue