Page 1 of 1

[FIX] fastest-mirror & wonky network

Posted: 04 Oct 2022, 19:48
by Rava

Code: Select all

root@porteus:~# fastest-mirror 
Checking fastest mirror ...

Results:


 Would you like to add  as your main Porteus server? [y/n]
This is due to my wonky network, when connected to an open WLAN, I have to confirm the terms & conditions in certain intervals anew.
At times my internet connection stays on, but everything https:// or Email-wise SMTP or SSL IMAP will not work. The only page https:// that will work is the confirmation page for that very WLAN.

Looking into the code of fastest-mirror I realized that it is a version I tweaked back in V2020-12-13 (I totally forgot about that. I blame the weirdness that was the lockdown-covid-madness back then up to mid/late 2021. :D )

Now I updated it to remove the possible error when someone else is on an open WLAN and stumbles upon the same wonkyness.

fastest-mirrorV2022-10-03:

Code: Select all

#!/bin/bash

# mirror_test.sh
# This script tests a list of porteus mirrors for speed
#
# AUTHOR: Lance Rushing <lance_rushing@hotmail.com>
# Modified for Porteus by brokenman <brokenman@porteus.org> , updated by Rava - V2020-12-13
# Modified by Rava V2022-10-03 - added some sanity checks for funky networks
# This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt

. /usr/share/porteus/porteus-functions
get_colors

## Vars
DUMP=/tmp/.fmr.tmp


## Trap ctrl C exits
cutandrun(){
[ -e $DUMP ] && rm $DUMP
exit
}
trap cutandrun SIGHUP SIGINT SIGTERM

is_online_url http://porteus.org/porteus-mirrors.txt || { red "The porteus server appears to be offline."; exit; }

## get list
MIRRORS=$(curl -s http://porteus.org/porteus-mirrors.txt)

## Number of seconds before the test is considered a failure
TIMEOUT="4"

## Sting to store results in
RESULTS=""

echo "Checking fastest mirror ..."
for MIRROR in $MIRRORS ; do
	
	echo -n "Testing ${MIRROR} "
	
	URL="${MIRROR}%{FILE}"
	
	TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL`
	
	if [ "$TIME" == "0.000" ] ; then
		red "Fail";
	else 
		if [ "$TIME"x == "x" ] ; then
			red "Fail";
		else
			echo $TIME
			RESULTS="${RESULTS}${TIME}\t${MIRROR}\n";
		fi
	fi

done;

echo -e "\nResults:"
echo -e $RESULTS | sort -n | tee $DUMP
FMIR=`sed '/^$/d' $DUMP | head -n1 | awk '{print$2}'`

echo

if [ "$FMIR"x == "x" ] ; then
	red "Something went wrong. Check your network and try again."
else
	read -p "`gettext " Would you like to add $FMIR as your main Porteus server? [y/n]"`" -n 1 -r -s && echo
	if [[ $REPLY =~ ^[Yy]$ ]]; then
		sed -i 's@^SERVER=.*@SERVER='$FMIR'@g' /etc/porteus.conf
		if [ $? -eq 0 ] ; then
			green "Porteus server updated in /etc/porteus.conf"
		else
			red "Couldn't update Porteus server in /etc/porteus.conf"
		fi
	fi
fi
cutandrun
Now when such funkyness happens, this is what fastest-mirror will display (in red, but [ code ] doesn't display colours:

Code: Select all

root@porteus:~# fastest-mirror 
Checking fastest mirror ...

Results:


 Something went wrong. Check your network and try again.

[FIX] fastest-mirror & wonky network

Posted: 04 Oct 2022, 19:56
by beny

Code: Select all

guest@porteus:~$ sh '/home/guest/fasten-mirror' 
Checking fastest mirror ...
Testing http://ftp.vim.org/ftp/os/Linux/distr/porteus/ 0.385158
Testing http://ftp.nluug.nl/os/Linux/distr/porteus/ 0.116705
Testing http://mirrors.dotsrc.org/porteus/ 0.125210
Testing https://mirrors.dotsrc.org/porteus/ 0.197889
Testing http://ftp.cc.uoc.gr/pub/linux/porteus/ 0.218973
Testing http://www6.frugalware.org/mirrors/linux/porteus/ 0.528346
Testing http://ftp.riken.jp/Linux/porteus/ 0.824983
Testing http://www.mirrorservice.org/sites/dl.porteus.org/ 0.090942
Testing http://linux.rz.rub.de/porteus/ 0.179146
Testing http://ftpmirror1.infania.net/mirror/porteus/ 0.399529
Testing https://mirror.yandex.ru/mirrors/porteus/ 0.328222

Results:

0.090942	http://www.mirrorservice.org/sites/dl.porteus.org/
0.116705	http://ftp.nluug.nl/os/Linux/distr/porteus/
0.125210	http://mirrors.dotsrc.org/porteus/
0.179146	http://linux.rz.rub.de/porteus/
0.197889	https://mirrors.dotsrc.org/porteus/
0.218973	http://ftp.cc.uoc.gr/pub/linux/porteus/
0.328222	https://mirror.yandex.ru/mirrors/porteus/
0.385158	http://ftp.vim.org/ftp/os/Linux/distr/porteus/
0.399529	http://ftpmirror1.infania.net/mirror/porteus/
0.528346	http://www6.frugalware.org/mirrors/linux/porteus/
0.824983	http://ftp.riken.jp/Linux/porteus/

 Would you like to add http://www.mirrorservice.org/sites/dl.porteus.org/ as your main Porteus server? [y/n]
i have copied the script and run this is the result

[FIX] fastest-mirror & wonky network

Posted: 04 Oct 2022, 20:08
by Rava
beny wrote:
04 Oct 2022, 19:56
i have copied the script and run this is the result
When your network works as it should, my updated version V2022-10-03 and the Porteus 5.0 version V2020-12-13 should behave the very same.

The update only will come in effect if you happen to stumble upon such a wonky WLAN as described above (usually you need a laptop and be in an Internet cafe or any other place where an open WLAN is - and all of these I happen upon want your confirmation to its terms and conditions - your home network should never behave in such a way.)

[FIX] fastest-mirror & wonky network

Posted: 07 Oct 2022, 01:53
by Rava
root@porteus:/# fastest-mirror
The porteus server appears to be offline.
root@porteus:/#
I then refreshed the Web connection on my i586 machine that is connected with the WLAN - without confirming anew to the terms and conditions, thus creating once again the wonky network - technically a network connection to the intertubes exist, but only to http:// and never to anything https:// .

The original fastest-mirror now reported this once more

Code: Select all

root@porteus:/# fastest-mirror 
Checking fastest mirror ...

Results:


 Would you like to add  as your main Porteus server? [y/n]
root@porteus:/# 
Updated the script with the above version and tried again
root@porteus:/# cp /welt/programmieren/bash/fastest-mirrorV2022-10-03 /usr/local/bin/fastest-mirror
/bin/cp: overwrite '/usr/local/bin/fastest-mirror'? y
root@porteus:/# fastest-mirror
Checking fastest mirror ...

Results:


Something went wrong. Check your network and try again.
root@porteus:/#
:D