WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Selecting different mirrors for appbrowser  (Read 2214 times)

Offline helander

  • Full Member
  • ***
  • Posts: 183
Selecting different mirrors for appbrowser
« on: July 05, 2009, 01:42:08 PM »
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:

Code: [Select]
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 ):

Code: [Select]
#!/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


Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Selecting different mirrors for appbrowser
« Reply #1 on: July 06, 2009, 12:13:50 AM »
Nice! I just created a list of sites that I can use with 'update' (which uses /opt/.tcrc) Thanks!