Commit Diff
Diff:
0dc1a0aaf80e9f5b8614126e7695d528a5e760a3
c5a4674bacd96a390519320eafbd2a8366795aa2
Commit:
c5a4674bacd96a390519320eafbd2a8366795aa2
Tree:
556fc3bb819513136cd03623edc9bf3f93253138
Author:
Fred. Galusik <f@galusik.fr>
Committer:
Fred. Galusik <f@galusik.fr>
Date:
Fri May 8 21:49:13 2020 UTC
Message:
some fixes
blob - 95750bbe453e6b2843a9a21758e454bd6aadab22
blob + 90c84f22ef3fd00dd8df4df60fd6bbadf1b51ef2
--- snaps
+++ snaps
@@ -37,6 +37,8 @@
#
########################################################################
+set -ue
+
###
### VARS
###
@@ -44,35 +46,25 @@
VERSION=1.3
# choose your MIRROR
-if [ ! "${MIRROR}" ]; then
- MIRROR=$(grep -v "^#" /etc/installurl)
-fi
+true ${MIRROR:=$(grep -v "^#" /etc/installurl)}
# curl is mandatory
-CURL=/usr/local/bin/curl
-if [[ ! -e ${CURL} ]]; then
- echo "{CURL} is requested to run this program. Aborting..."
+if [ ! "$(which curl 2>/dev/null)" ]; then
+ echo "WARNING: 'curl' is requested to run this program. Aborting..."
exit 1
fi
#
-CURRENTSYS=$(sed q /var/run/dmesg.boot)
ARCH=$(uname -m)
SHA=SHA256
BASE=/snapshots/${ARCH}/
BASEF=/snapshots/${ARCH}/${SHA}
PKGSF=/snapshots/packages/${ARCH}/${SHA}
-HTTPSLIST='https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/www/httpslist'
-
GET='ftp -n -m -C'
LOGF=/var/log/snaps.log
-NOW=$(date "+ %Y-%m-%d %R")
-REMOTESNAPS='https://framagit.org/fredg/snaps/raw/master/snaps'
-LASTSNAPS=/tmp/snaps
-
###
###
###
@@ -101,16 +93,18 @@ usage() {
s_root() {
if [[ $(id -u) != "0" ]]; then
- echo "WARNING: You need to be root to do this!" 1>&2
+ echo "WARNING: You need to be root to do this! Aborting..." 1>&2
exit 1
fi
}
toupgrade() {
+ REMOTESNAPS='https://framagit.org/fredg/snaps/raw/master/snaps'
+ LASTSNAPS=/tmp/snaps
echo "Checking snaps release..."
if [[ -f "${LASTSNAPS}" ]]; then
- rm -f ${LASTSNAPS}
+ rm -f "${LASTSNAPS}"
fi
if $GET -V -o "${LASTSNAPS}" "${REMOTESNAPS}"; then
REMOTEVERSION=$(awk -F '=' '/^VERSION=/ { print $2 }' "${LASTSNAPS}")
@@ -154,14 +148,15 @@ s_upports() {
s_cur() {
+ CURRENTSYS=$(sed q /var/run/dmesg.boot)
echo "=== LOCAL BASE BUILD DATE ==="
echo "${CURRENTSYS}"
}
s_when() {
- CURLB="$(${CURL} -sI "${MIRROR}${BASEF}" | grep Last-Modified)"
- CURLP="$(${CURL} -sI "${MIRROR}${PKGSF}" | 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}"
@@ -170,6 +165,7 @@ s_when() {
s_sysup() {
+ NOW=$(date "+ %Y-%m-%d %R")
echo ""
echo -n "Do you want to run 'sysupgrade -s' ? (y/n): "
read -r _c
@@ -188,24 +184,25 @@ s_sysup() {
read_cur() {
FAQ='https://www.openbsd.org/faq/current.html'
- if [ $(which links 2>/dev/null) ]; then
+ if [ "$(which links 2>/dev/null)" ]; then
READ='links -dump'
- elif [ $(which lynx 2>/dev/null) ]; then
+ elif [ "$(which lynx 2>/dev/null)" ]; then
READ='lynx --dump'
else
- echo "You need 'links' or 'lynx' to get the FAQ/CURRENT. Aborting..."
+ echo "You need 'links' or 'lynx' to read the online FAQ/CURRENT. Aborting..."
exit 1
fi
${READ} ${FAQ} | less
}
all_mirrors() {
- MIRRORLIST=$(${CURL} ${HTTPSLIST} | awk '{print $1}')
+ HTTPSLIST='https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/www/httpslist'
+ MIRRORLIST=$(curl ${HTTPSLIST} | awk '{print $1}')
for _m in ${MIRRORLIST}
do
- CB="$(${CURL} -sI "${_m}${BASEF}" | grep Last-Modified |\
+ CB="$(curl -sI "${_m}${BASEF}" | grep Last-Modified |\
sed 's/Last-Modified: //')"
- CP="$(${CURL} -sI "${_m}${PKGSF}" | 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