Commit Diff
Diff:
02a9028e051d2344d0a554843e8c11826e02ea90
cf2b0082d3c6800651e0c21a0760d96729d1cd3a
Commit:
cf2b0082d3c6800651e0c21a0760d96729d1cd3a
Tree:
0ea4b9a2f43ed814e3cb7c876440fffa8992a2bc
Author:
Fred. Galusik <f@galusik.fr>
Committer:
Fred. Galusik <f@galusik.fr>
Date:
Fri May 1 19:29:14 2020 UTC
Message:
upd
blob - 5f37951e02f1e30624a893fab1af82974b5417ae
blob + 11e591b7b5c7d67d1619f0106c67750427586b99
--- snaps
+++ snaps
@@ -56,17 +56,15 @@ if [[ ! -e ${CURL} ]]; then
fi
#
-CURRENTSYS=$(sed 1q /var/run/dmesg.boot)
+CURRENTSYS=$(sed q /var/run/dmesg.boot)
ARCH=$(uname -m)
+SHA=SHA256
BASE=/snapshots/${ARCH}/
-PACKAGES=/snapshots/packages/${ARCH}/
+BASEF=/snapshots/${ARCH}/${SHA}
+PKGSF=/snapshots/packages/${ARCH}/${SHA}
-MIRRORB=${MIRROR}/snapshots/${ARCH}/
-MIRRORPKG=${MIRROR}/snapshots/packages/${ARCH}/
-HTTPSLIST=https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/www/httpslist
+HTTPSLIST='https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/www/httpslist'
-SHAF=SHA256
-
GET='ftp -n -m -C'
LOGF=/var/log/snaps.log
@@ -81,7 +79,7 @@ LASTSNAPS=/tmp/snaps
usage() {
- echo "${0##*/} $VERSION"
+ echo "${0##*/} ${VERSION}"
echo "Usage: ${0##*/} [-scpluh]"
echo ""
echo " -s check \$MIRROR freshness & choose to sysupgrade or not"
@@ -91,7 +89,7 @@ usage() {
echo " -u upgrade snaps to last version"
echo " -h print this help and exit"
echo ""
- echo "MIRROR is based upon /etc/installurl and set to: $MIRROR"
+ echo "MIRROR is based upon /etc/installurl and set to: ${MIRROR}"
echo ""
echo "You can set it manually:"
echo "\$ MIRROR=http://mirrors.ircam.fr/pub/OpenBSD snaps -c"
@@ -109,14 +107,14 @@ s_root() {
toupgrade() {
echo "Checking snaps release..."
- if [[ -f "$LASTSNAPS" ]]; then
- rm -f $LASTSNAPS
+ if [[ -f "${LASTSNAPS}" ]]; then
+ rm -f ${LASTSNAPS}
fi
- if $GET -V -o "$LASTSNAPS" "$REMOTESNAPS"; then
- REMOTEVERSION=$(awk -F '=' '/^VERSION=/ { print $2 }' "$LASTSNAPS")
- if [ "$VERSION" != "$REMOTEVERSION" ]; then
+ if $GET -V -o "${LASTSNAPS}" "${REMOTESNAPS}"; then
+ REMOTEVERSION=$(awk -F '=' '/^VERSION=/ { print $2 }' "${LASTSNAPS}")
+ if [ "${VERSION}" != "${REMOTEVERSION}" ]; then
echo "WARNING: snaps is not up-to-date !"
- echo "Last version: $REMOTEVERSION"
+ echo "Last version: ${REMOTEVERSION}"
echo "To upgrade, run 'snaps -u'"
else
echo "GOOD: snaps is up-to-date."
@@ -131,15 +129,15 @@ toupgrade() {
upgrade() {
SELFPATH=$(dirname "$(readlink -f -- "$0")")
echo "Downloading last snaps version..."
- $GET -o "$SELFPATH" "$REMOTESNAPS"
+ $GET -o "${SELFPATH}" "${REMOTESNAPS}"
}
get_log() {
- if [[ -f "$LOGF" ]]; then
- tail -n 3 $LOGF
+ if [[ -f "${LOGF}" ]]; then
+ tail -n 3 ${LOGF}
else
- echo "No $LOGF file. Seems you have not yet played with snaps."
+ echo "No ${LOGF} file. Seems you have not yet played with snaps."
exit 1
fi
}
@@ -160,8 +158,8 @@ s_cur() {
s_when() {
- CURLB="$(${CURL} -sI "${MIRRORB}${SHAF}" | grep Last-Modified)"
- CURLP="$(${CURL} -sI "${MIRRORPKG}${SHAF}" | grep Last-Modified)"
+ CURLB="$(${CURL} -sI "${MIRROR}${BASEF}" | grep Last-Modified)"
+ CURLP="$(${CURL} -sI "${MIRROR}${PKGSF}" | grep Last-Modified)"
echo "=== ONLINE BASE AND PACKAGES BUILD DATE ==="
echo "From ${MIRROR}"
echo "Base (${ARCH}) => ${CURLB}"
@@ -169,7 +167,7 @@ s_when() {
}
-s_sysup () {
+s_sysup() {
echo ""
echo -n "Do you want to run 'sysupgrade -s' ? (y/n): "
read -r _c
@@ -181,18 +179,18 @@ s_sysup () {
exit 1
;;
esac
- echo "${NOW} FROM ${MIRRORB}" >> ${LOGF}
+ echo "${NOW} FROM ${MIRROR}${BASE}" >> ${LOGF}
sysupgrade -s
}
-all_mirrors () {
+all_mirrors() {
MIRRORLIST=$(${CURL} ${HTTPSLIST} | awk '{print $1}')
for _m in ${MIRRORLIST}
do
- CB="$(${CURL} -sI "${_m}${BASE}${SHAF}" | grep Last-Modified |\
+ CB="$(${CURL} -sI "${_m}${BASEF}" | grep Last-Modified |\
sed 's/Last-Modified: //')"
- CP="$(${CURL} -sI "${_m}${PACKAGES}${SHAF}" | grep Last-Modified |\
+ CP="$(${CURL} -sI "${_m}${PKGSF}" | 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
Frédéric Galusik