@neo: Are you using the full wget or the busybox version? Full wget would,
in theory, resort back to its compiled default timeout. BB wget "should" timeout after 10 seconds of complete silence, but if a mirror answered and error'ed (such as an FTP server which answers the caller, but the DIRECTORY in question no longer exists) wget wouldn't "fail" and thus timeout may get bypassed -- again, this is
in theory.
@everyone:
Just a suggestion with the mirror system; the way
we do things here is to...
- Take /opt/tcemirror and create a fresh mirror list with it (just in case tcemirror contains a custom URL)
- Take mirrors.tcz and put that list of links into our fresh list from above
- PING each of the listed servers (3 times/1 sec interval) with a wget timeout of 10 seconds, KILL the threads that time-out after OUR OWN 5 seconds
- Of the remaining servers which passed the PING test, DOWNLOAD a copy of mirrors.tcz (~4KB) from each; the first to finish replaces /opt/tcemirror
A stripped version is included which simply doesn't include the PING tests and should act as a close replacement to the existing mirror selector.
I didn't build a GUI version; the goal was with or without desktop and for my own personal speed.
(Note: repo.tinycorelinux ignores ICMP so it doesn't allow pinging anyhow, thus why it's left out here.)
OUR TIMEOUT can be set in the first few lines of the script. This should be <10 seconds none the less.
#!/bin/sh
TIMEOUT=5
#### Make sure we're not running as ROOT
if [ "$(whoami)" == "root" ]; then
. /etc/init.d/tc-functions
echo "${YELLOW}You must not run this as ROOT${NORMAL}"
exit 1
fi
#### Make sure we have mirrors.tcz installed and loaded
if [ ! -d /tmp/tcloop/mirrors ]; then
if [ ! -f /etc/sysconfig/tcedir/optional/mirrors.tcz ]; then
tce-load -w mirrors.tcz
fi
tce-load -i /etc/sysconfig/tcedir/optional/mirrors.tcz
fi
#### Clean and create our testing grounds
mkdir -p /tmp/mymirrors && rm /tmp/mymirrors -fR
mkdir -p /tmp/mymirrors/cmd /tmp/mymirrors/results /tmp/mymirrors/junk
##############################################
#### Go straight through our mirror list and WGET test them all! ####
##############################################
VER=$(version | awk -F. '{print $1}')
URI="${VER}.x/x86/tcz"
# Be sure we include /opt/tcemirror in case it's custom #
if [ ! -f /tmp/mymirrors.txt ]; then
cat /opt/tcemirror > /tmp/mymirrors.txt
cat /usr/local/share/mirrors >> /tmp/mymirrors.txt
fi
CNT=0
clear
while read -r line
do
test=$(echo $line)
if [ ! "${test}" == "" ]; then
SERV=$(echo $line | awk -F"/" '{print $3}' | awk -F: '{print $1}')
echo "#!/bin/sh" > /tmp/mymirrors/cmd/${CNT}.sh
echo "wget --no-check-certificate -O /tmp/mymirrors/junk/${SERV} ${line}${URI}/mirrors.tcz 2>/tmp/junk.txt" >> /tmp/mymirrors/cmd/${CNT}.sh
echo "echo \"${line}\" >> /tmp/mymirrors/test2.lst" >> /tmp/mymirrors/cmd/${CNT}.sh
chmod +x /tmp/mymirrors/cmd/${CNT}.sh
CNT=$(expr $CNT + 1)
fi
done < /tmp/mymirrors.txt
echo "Testing Mirrors..."
cd /tmp/mymirrors/cmd
for file in *
do
sh $file >/dev/null 2>&1 &
done
sleep $TIMEOUT
# Kill only processes which are WGET and contain "junk" (2>/tmp/junk.txt) JUST IN CASE :)
for item in $(ps -a | grep wget | grep junk | grep -v grep | grep -v sh | awk '{print $1}')
do
sudo kill $item
done
while read -r line
do
if [ ! "${line}" == "" ]; then
echo $line > /opt/tcemirror
break
fi
done < /tmp/mymirrors/test2.lst
cp /tmp/mymirrors/test2.lst /opt/tcemirror.lst
cat /opt/tcemirror
cd /opt
rm /tmp/mymirrors -fR