DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 4th April 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default Checking OpenBSD snapshot mirror status

A simple shell script to locate an OpenBSD https mirror with the latest snapshot.
The script retrieves the BUILDINFO file from several mirrors and sorts these on the Unix timestamp (number of seconds since 1970) which is the third word or key.

An example BUILDINFO:
Code:
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021
You can feed the number 1617495973 to date(1) to see your local time as follows:

Code:
$ date -r 1617495973
Sun Apr  4 02:26:13 CEST 2021
Or double check that really is the timestamp in the administrative UTC timezone:
Code:
$ env TZ=UTC date -r 1617495973
Sun Apr  4 00:26:13 UTC 2021
An example of the produced output:
Code:
$ ./getBUILDINFO.sh  
./getBUILDINFO.sh: /home/snap2/tmp directory cleared ....

--- Alberta -----------
Trying 129.128.5.191...
Requesting https://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/BUILDINFO
100% |*********************************************|    54       00:00    
54 bytes received in 0.00 seconds (70.62 KB/s)

[snip]

--- Cloudfare -----------
Trying 104.17.249.92...
Requesting https://cloudflare.cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/BUILDINFO
100% |*********************************************|    54       00:00    
54 bytes received in 0.00 seconds (70.61 KB/s)

Sun 4-Apr-2021 06:19 CEST +0200 = Sun 4-Apr-2021 04:19 UTC

Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Aachen
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Ede
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Nluug
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021 - Alberta
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021 - Cloudfare
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021 - Copenhagen
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021 - Stockholm
A previous and thus older run produced:
Code:
Build date: 1617392997 - Fri Apr  2 19:49:57 UTC 2021 - Nluug
Build date: 1617436633 - Sat Apr  3 07:57:13 UTC 2021 - Aachen
Build date: 1617436633 - Sat Apr  3 07:57:13 UTC 2021 - Ede
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Alberta
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Cloudfare
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Copenhagen
Build date: 1617469416 - Sat Apr  3 17:03:36 UTC 2021 - Stockholm
The script:
Code:
#/bin/sh
# (c) 2021 j65nko daemonforums.org 
# OpenBSD License: https://cvsweb.openbsd.org/src/share/misc/license.template?rev=HEAD

ARCH=amd64
DIR=snapshots/$ARCH
# --- Directory STORAGE will be emptied!
STORAGE=~/tmp
mkdir -p ~/tmp

# --- https/ftp sites from openbsd.org/ftp.html

Alberta=https://ftp.openbsd.org/pub/OpenBSD
Stockholm=https://ftp.eu.openbsd.org/pub/OpenBSD
Nluug=https://ftp.nluug.nl/OpenBSD
Ede=https://ftp.bit.nl/pub/OpenBSD
Copenhagen=https://mirror.one.com/pub/OpenBSD
Aachen=https://ftp.halifax.rwth-aachen.de/pub/OpenBSD
Cloudfare=https://cloudflare.cdn.openbsd.org/pub/OpenBSD

rm $STORAGE/{BUILDINFO_,tmp_}* && echo $0: $STORAGE directory cleared ....

for site in Alberta Stockholm Nluug Ede Copenhagen Aachen Cloudfare; do
    eval SITE=\${$site}
    echo ; echo --- $site -----------
    ftp -4 -o $STORAGE/tmp_$site $SITE/$DIR/BUILDINFO  
    sed -e "s/$/ - $site/" $STORAGE/tmp_$site >$STORAGE/BUILDINFO_$site 
done

echo
echo $(date  "+%a %v %R %Z %z") =  $(env TZ=UTC date "+%a %v %R %Z")
echo
cat $STORAGE/BUILDINFO_* | sort -k3
# ----
The BUILDINFO's files are first saved as temporary files with the name of the https site tacked on, then fed to sed(1) to append the mirror identifier to the original contents:

Code:
ls -l ; cat tmp_Alberta BUILDINFO_Alberta
-rw-r--r--  1 snap2  snap2  63 Apr  4 06:19 BUILDINFO_Aachen
-rw-r--r--  1 snap2  snap2  64 Apr  4 06:19 BUILDINFO_Alberta
-rw-r--r--  1 snap2  snap2  66 Apr  4 06:19 BUILDINFO_Cloudfare
-rw-r--r--  1 snap2  snap2  67 Apr  4 06:19 BUILDINFO_Copenhagen
-rw-r--r--  1 snap2  snap2  60 Apr  4 06:19 BUILDINFO_Ede
-rw-r--r--  1 snap2  snap2  62 Apr  4 06:19 BUILDINFO_Nluug
-rw-r--r--  1 snap2  snap2  66 Apr  4 06:19 BUILDINFO_Stockholm
-rw-r--r--  1 snap2  snap2  54 Apr  3 19:03 tmp_Aachen
-rw-r--r--  1 snap2  snap2  54 Apr  4 02:26 tmp_Alberta
-rw-r--r--  1 snap2  snap2  54 Apr  4 02:26 tmp_Cloudfare
-rw-r--r--  1 snap2  snap2  54 Apr  4 02:26 tmp_Copenhagen
-rw-r--r--  1 snap2  snap2  54 Apr  3 19:03 tmp_Ede
-rw-r--r--  1 snap2  snap2  54 Apr  3 19:03 tmp_Nluug
-rw-r--r--  1 snap2  snap2  54 Apr  4 02:26 tmp_Stockholm

Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021
Build date: 1617495973 - Sun Apr  4 00:26:13 UTC 2021 - Alberta
The BUILDINFO_* files are then sorted with $ sort -k3 to produce the output.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 4th April 2021 at 05:21 AM.
Reply With Quote
  #2   (View Single Post)  
Old 4th April 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

The script for downloading.
Attached Files
File Type: txt getBUILDINFO.txt (1.0 KB, 36 views)
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 4th April 2021
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Nice! For decades, my checks have always been manual.
Reply With Quote
  #4   (View Single Post)  
Old 4th April 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

@jggimi
In my Tracking OpenBSD snapshots with some simple shell scripts guide from December 2009, I posted another approach that included the snapshot packages. You must have missed that one
Being built on ftp and the ftp-only .netrc file, those scripts stopped working when the main Alberta site switched from ftp to http-only server.

Because of the emergence of the BUILDINFO file and the inclusion of index.txt files, the process of snapshot tracking can be simplified enormously compared with what I posted in Dec 2009. I am working on it ......
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
Reply

Tags
openbsd snapshots, snapshots

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenBSD 5.5 snapshot/Gnome 3.10.2 config issues JWJones OpenBSD Packages and Ports 8 18th March 2014 11:50 AM
OpenBSD i386 snapshot & PAE on VirtualBox aleunix OpenBSD Installation and Upgrading 2 1st March 2012 06:44 PM
Apached checking its own status? Mantazz FreeBSD Ports and Packages 5 4th August 2010 04:11 AM
Automating OpenBSD snapshot downloads with a .netrc file J65nko Guides 1 7th January 2010 03:09 AM
Status of Xen on OpenBSD Oko OpenBSD General 2 19th June 2008 09:02 PM


All times are GMT. The time now is 09:58 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick