Commit Diff
Diff:
2ab8393b1b8f2aaefae8ec60eb38af2737fea0a4
02a9028e051d2344d0a554843e8c11826e02ea90
Commit:
02a9028e051d2344d0a554843e8c11826e02ea90
Tree:
a9c48a215d083ea02229551ced88dc272301597f
Author:
Fred. Galusik <f@galusik.fr>
Committer:
Fred. Galusik <f@galusik.fr>
Date:
Wed Apr 29 20:51:15 2020 UTC
Message:
add all_mirror : FIXME try to figure out how to print 1 mirror per line
blob - e6d78a3614ba69f59507f81c33ffe23451e72194
blob + 5f37951e02f1e30624a893fab1af82974b5417ae
--- snaps
+++ snaps
@@ -43,14 +43,27 @@
VERSION=1.3
-if [ ! "$MIRROR" ]; then
+# choose your MIRROR
+if [ ! "${MIRROR}" ]; then
MIRROR=$(grep -v "^#" /etc/installurl)
fi
+# curl is mandatory
+CURL=/usr/local/bin/curl
+if [[ ! -e ${CURL} ]]; then
+ echo "{CURL} is requested to run this program. Aborting..."
+ exit 1
+fi
+
+#
CURRENTSYS=$(sed 1q /var/run/dmesg.boot)
ARCH=$(uname -m)
+BASE=/snapshots/${ARCH}/
+PACKAGES=/snapshots/packages/${ARCH}/
+
MIRRORB=${MIRROR}/snapshots/${ARCH}/
MIRRORPKG=${MIRROR}/snapshots/packages/${ARCH}/
+HTTPSLIST=https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/www/httpslist
SHAF=SHA256
@@ -147,19 +160,12 @@ s_cur() {
s_when() {
- # will only be done if curl from port/package is installed
- CURL=/usr/local/bin/curl
- if [[ -e ${CURL} ]]; then
- CURLB="$(${CURL} -sI "${MIRRORB}${SHAF}" | grep Last-Modified)"
- CURLP="$(${CURL} -sI "${MIRRORPKG}${SHAF}" | grep Last-Modified)"
- echo "=== ONLINE BASE AND PACKAGES BUILD DATE ==="
- echo "From ${MIRROR}"
- echo "Base (${ARCH}) => ${CURLB}"
- echo "Packages (${ARCH}) => ${CURLP}"
- else
- echo "${CURL} is required to run this program. Aborting..."
- exit 1
- fi
+ CURLB="$(${CURL} -sI "${MIRRORB}${SHAF}" | grep Last-Modified)"
+ CURLP="$(${CURL} -sI "${MIRRORPKG}${SHAF}" | grep Last-Modified)"
+ echo "=== ONLINE BASE AND PACKAGES BUILD DATE ==="
+ echo "From ${MIRROR}"
+ echo "Base (${ARCH}) => ${CURLB}"
+ echo "Packages (${ARCH}) => ${CURLP}"
}
@@ -180,6 +186,26 @@ s_sysup () {
}
+all_mirrors () {
+ MIRRORLIST=$(${CURL} ${HTTPSLIST} | awk '{print $1}')
+ for _m in ${MIRRORLIST}
+ do
+ CB="$(${CURL} -sI "${_m}${BASE}${SHAF}" | grep Last-Modified |\
+ sed 's/Last-Modified: //')"
+ CP="$(${CURL} -sI "${_m}${PACKAGES}${SHAF}" | grep Last-Modified |\
+ sed 's/Last-Modified: //')"
+ # only print mirror which give an answer
+ # FIXME try to figure out how to print 1 mirror per line
+ if [ "${CB}" ]; then
+ echo "${_m}"
+ echo "${CB}"
+ echo "${CP}"
+ echo ""
+ fi
+ done
+}
+
+
##
## Run
##
@@ -196,6 +222,9 @@ case $1 in
-c)
s_when
;;
+ -a)
+ all_mirrors
+ ;;
-p)
s_upports
;;
Frédéric Galusik