The script in the code section below allows you to select a download mirror from a list of mirrors found in the file tcmirrors located in your home directory. This file have one line for each mirror according to the following example:
MirrDef: distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x http
MirrDef: lars-helander.name/tc/2.x http
The script ( I call it tcmirror ):
#!/bin/sh
exit_script()
{
rm /tmp/mirrselans 2>/dev/null
exit 0
}
isxwin() {
# return 0 if started under x-window, 1 otherwise
[ -z "$DISPLAY" ] && return 1
[ -n "$WINDOWID" ] && return 0
case "$TERM" in xterm*|rxvt) return 0;; esac
return 1
}
XDIALOG=`which Xdialog`
DIALOG=`which dialog`
isxwin && [ -n "$XDIALOG" ] && DIALOG=$XDIALOG
MIRROR=""
mirrors_dialog()
{
MIRRORS=`cat ~/tcmirrors | awk '/MirrDef:/ {printf "%s://%s - ",$3,$2}'`
$DIALOG --title "Select TC mirror" --menu "Select TC mirror" 12 70 5 \
$MIRRORS \
2>/tmp/mirrselans
RESULT="$?"
case $RESULT in
0) MIRROR="$(cat /tmp/mirrselans)";;
*) exit_script;;
esac
}
mirrors_dialog
MIRR=`echo $MIRROR | sed 's%://% %' | awk '{print $2}'`
PROT=`echo $MIRROR | sed 's%://% %' | awk '{print $1}'`
REPO=`cat /opt/.tcrc | awk '/Repository:/ {print $2}'`
echo Mirror: $MIRR > /opt/.tcrc
echo Protocol: $PROT >> /opt/.tcrc
echo Repository: $REPO >> /opt/.tcrc