[INFO & SCRIPT] Slackware Mirror Settings for USM

Post tutorials, HOWTO's and other useful resources here.
Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

[INFO & SCRIPT] Slackware Mirror Settings for USM

Post#1 by Bogomips » 15 Jun 2017, 12:10

.
USM UPDATE PROCEDURE

Established a Procedure to follow at Start of Session:
  1. Run script to set the fastest Slackware mirrors for USM (aks sesm.sh) in bash shell:

    Code: Select all

    guest@porteus:~$ bash  sesm.sh  all
  2. In root terminal run usm -u all
  3. If there is an Issue with a Repository Mirror, run script to set an alternate fast mirror (aka safm.sh) in bash shell. For example:
    • Code: Select all

      root@porteus:/home/guest# time usm -u all
       Starting slackware database update
      Downloading: vercheck.txt  DONE
      Downloading: CHECKSUMS.md5  DONE
      Downloading: MANIFEST.bz2  DONE
      Downloading: PACKAGES.TXT  DONE
      Downloading: LIBS.TXT.gz  DONE
       There was a problem downloading the file:
      
    • Invocation to use: bash safm.sh <repo>, where repo is one of: slackware, slackwarepatches, salix, slacky.
    • Code: Select all

      guest@porteus:~$ bash  safm.sh slackware
      
      Current Mirror: ftp://elektroni.phys.tut.fi/
      Alternative Mirrors
      1) http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.087508
      2) http://mirror.nl.leaseweb.net/slackware/ 0.099194
      3) http://mirror.ovh.net/mirrors/ftp.slackware.com/ 0.099655
      4) http://mirrors.dotsrc.org/.disk1/slackware/ 0.106202
      5) http://ftp1.uninett.no/slackware/ 0.108231
      6) http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.112806
      #? 1
      Done!
      slackware mirror set to: http://ftp.nluug.nl/os/Linux/distr/slackware/
      Another Alternative? [Y/n]
      Terminating.
      
  4. Repeat from 3. until completed:

    Code: Select all

    Downloading: extra-deps.txt  DONE
    Downloading: ignore-deps.txt  DONE
    
Always used to approach the update with trepidation, not knowing if usm would be able to update cleanly. However since doing the scripts, so far so good and always managed to get usm to complete the update. :)

As of Mon Jul 24 17:08:33 UTC 2017:
  • Script to Set the fastest Slackware Mirrors (aka sesm.sh)

    Code: Select all

    #!/bin/bash
    # sesm.sh   Set the Slackware Miirors for usm Repos    Bogomips    2017-06-13 19:33:50
    # fasm.sh   Adaptation by Bogomips to Set Fastest Slackware Repository Mirror   2017-06-07 21:35:10
    # Internal Reference:   usm/sesm_240717.sh
    # Last Update   2017-07-20 00:38:14     Failure of All Mirrors of Reposiory (single mirror normally) does not lead to Termination.
    # 2017-07-19 14:32:46   Uniformity: Replaced bad() with bad() from 'safm.sh'.
    # 2017-06-30 21:49:19   Comments; bad(): Output msgs + formatting
    # 2017-06-29 23:22:09   Sourcing:  FUNCNAME[1]==source    (,|source) <file>     2017-06-29 23:19:54
    # 2017-06-29 16:11:24   Streamlinig with Constants: $hash & $proto
    # 2017-06-29 16:11:24   Impleemented Single Mirror Repo Exception from Exclusion
    # 2017-06-27 22:50:12   Bad Mirrors list in file '.usm/badmirrors.txt' merge with Command Line URL Exclusion List
    
    # 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>
    # This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt
    # Constants
    proto="(http|ftp)://[^[:space:]]+";
    hash="[[:space:]]*#?[[:space:]]*"
    sus="Argument usage:\t\tall\t[<Toggle Debug: 0/1>]\t[ URL .. ]\nURL .. Optional Exclusion Mirror List on Command Line\nOptional Exclusion File of URLs: .usm/badmirrors.txt (following format of 'mirrors-<repo>,txt')"
    fs0="Argument usage:\t\t<Repository>\t\t"; fus=$fs0[${sus#*[};  #   2017-06-30 22:53:54
    fsm="Warning! No Mirror Timings obtained for Repo: \${1^^}\$'\n'No Mirror Alteration made.";
    # Assoc Arrays to be Global
    unset allm; declare -A allm;    # Used to Validate URL
    unset bay; declare -A bay;      # Used to Skip testing of URL
    ## Verification by Key Press		2015-02-12 00:11:36 
    kpv ()
    {
    local nu; local k;
        while (( 1 ))
        do
          read -s -n1 -p "$1? [Y/n]" k
          case $k in
          "$nu"	)	echo ""; return 0;;
          [yY]	)	echo ""; return 0;;
          [nN]	)	echo ""; return 1;;
    	*	)  echo $'\n'"Invalid Key '$k'"
          esac
        done
    }
    # Function bad()
    # Ascertains if a debug option was defaulted, and sets debug toggle accordingly.
    
    # Exclusion from Testing
    #   Cmd Line URLs
    # Checks Protocols of Cmd Line URLs
    # Checks Relevance of Cmd Line URLs (corresponds to entry in 'mirrors-<repo>.txt')
    # Lists them out.
    
    # Exclusion from Testing
    # File ('.usm/badmirrors.txt' similar format to 'mirrors-<repo>.txt' files)  URLs
    # Option to Proceed if no URLs found in file.
    # Checks Relevance of Cmd Line URLs (correspond to entry in 'mirrors-<repo>.txt'?)
    # List irrelevant URLs found in file together with containing line in file.
    # Option to Proceed if irrelevant URLs found in file.(not in 'mirrors-<repo>.txt')
    bad ()
    {
    err="Error! "
    bm=("Mirror Parameter neither http nor ftp:" "Command Line URL not found in Mirrors' List:");
    # Command Line      2017-06-25 15:01:32
    #   Debug Option?
    dfl=""; [[ $2 =~ ^[0-9]+$ ]] && { dfl=$2; shift; }
    shift;
    
    # Split Cmd Line URLs into pass 'pay' and fail 'fay' categories.
    unset pay fay ret; [[ $* ]] && echo;                    # No Cmd Line URLs
    for l in $*; do if [[ $l =~ ^$proto ]]; then    pay+=($l);    else    fay+=($l); fi done
    
    # Announce Erronous Mirrors
    if [[ -v fay ]]; then ret=6; echo $err${bm[ret-6]}; 
        for l in ${fay[*]}; do echo $l; done
    fi
    
    # Check Cmd Line URL for Relevance
    
    #       Array allm[*] populated with URLs from 'mirrors-<repo>.txt' Time (0.114")
    for r in $DISTROS; do 
        readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$r.txt);
        for l in "${f[@]}"; do [[ $l =~ ^$hash($proto) ]] && allm[${BASH_REMATCH[1]%/}]=; done
    #    for l in "${f[@]}"; do [[ $l =~ ^$hash((http|ftp).*) ]] && allm[${BASH_REMATCH[1]%/}]=; done
    done    
    
    # Assoc Array 'allm' of All Mirrors now Set
    
    for u in ${pay[*]}; do if [[ ! -v allm[${u%/}] ]]; then [[ ret++ -lt 7 ]] && { ret=7; echo $err${bm[ret-6]}; }
        echo $u; fi
    done
    ((ret)) && return $ret;             # Irrelevant URL Error Return.
    
    # Announce Cmd Line URLs
    if ((${#pay[*]})); then    echo Exclusion URL Specified on Command Line:;
        for u in ${pay[*]}; do bay[${u%/}]= ; echo $u; done
    fi
    # Keep Count of Cmd Line URLs
    ucmd=${#pay[*]}; unset ufle umge
    
    # Call from safm?                           2017-07-11 13:39:16
    [[ ${FUNCNAME[1]} == safm ]] && return 0;
    
    # Check for file: '.usm/badmirrors.txt'
    [[ -f  .usm/badmirrors.txt ]] || { echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=0\tMerged(Unique) URLs=${#bay[*]}"; return 0; }
    
    mc=$(grep -Ec "^$hash$proto" .usm/badmirrors.txt);    # Mirror Count
    if ! ((mc)); then echo "No URL found in File '.usm/badmirrors.txt'";
        kpv Proceed || return 10; return 0;
    fi
    # Keep Count of File URLs
    ufle=$mc;
    
    # Validate the URLs in File
    #   Read URLs into Work Array
    readarray -t way < <(grep -E "^$hash$proto" .usm/badmirrors.txt)
    # readarray -t way < <(grep -E "^\s*#*\s*$proto" .usm/badmirrors.txt)
    [[ mc -ne ${#way[*]} ]] && { echo -e "Internal Error! grep/bash count differ: mc=$mc\t\${#way[*]}=${#way[*]}"; return 11; };
    
    # Relevance Check for File URLs
    unset fay;          # Fail Array
    for w in "${way[@]}";
    do 
        [[ $w =~ ^$hash($proto) ]] || { echo "Internal Error! grep/bash RE clash: w='$w'"; return 12; }
        u=${BASH_REMATCH[1]%/};         # Isolated URL
        if [[ ! -v allm[$u] ]]; then    [[ -v fay ]] || { ret=12; echo $err${bm[1]/     Command Line/File}; }
            fay+=($u); [[ $u == $w ]] && echo $u || echo $u$'\n'$w; echo;
        else
            bay[$u]=;
        fi
    done
    ((ret)) && { kpv Proceed || return $ret; }
    
    # Keep Count of Unique URLs
    umge=${#bay[*]}
    ((ucmd+ufle)) && echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=$ufle\tMerged(Unique) URLs=$umge"
    # "Cmd Line URLs=$ucmd\tFile URLs=$ufle\t\tMerged(Unique) URLs=$umge"
    return 0;
    }
    # Get Fastest Mirror
    fam() {
    # 1st Parameter if set, toggles Selection to only Process Bad Mirrors.   2017-06-28 23:01:06
    # 2nd Parameter aaumed never to be set
    
    ## get list
    local -n MIRRORS=${2:-may};         # Changed from 1s to 2nd Para.  2017-06-29 15:58:55
    
    ## Number of seconds before the test is considered a failure
    TIMEOUT="4"
    
    ## String to store results in
    RESULTS=""
    # Elapsed Time Check        Output an Update every 5 sec.
    let x=SECONDS;
    
    for ((i=0; i<${#MIRRORS[*]}; i++)) ; do     MIRROR=${MIRRORS[i]};
        let y=SECONDS;
        if [[ y-x -gt 5 && i -gt 0 ]]; then
            tail -n1 $RAW;
            echo -e "Mirrors=${#MIRRORS[*]}\t\tProcessed=$i\t\tRemaining=$((${#MIRRORS[*]}-i))";
            let x=SECONDS;      # Reset
        fi
        # Implementing Exclusive OR, Ensuress Processing if TRUE.    2017-06-28 19:51:57
        [[ ! $1 && ${bay[${MIRROR%/}]+x} ]] && continue;    # Exclude   2017-06-25 22:26:41
        [[ $1 && ! ${bay[${MIRROR%/}]+x} ]] && continue;    # Exclude   2017-06-28 19:51:57     2nd Part of XOR
        echo -n "Testing ${MIRROR} " >> $RAW
     
        URL="${MIRROR}%{FILE}"
    	
    	TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL`
    	
    	if [[ $TIME =~ ^0.000 ]] ; then
    		echo "Fail" >> $RAW;
    	else 
    		echo $TIME >> $RAW
    		RESULTS="${RESULTS}${TIME}\t${MIRROR}\n";
    	fi
    done;
    
    echo -e $RESULTS | sort -n > $DUMP
    FMIR=""; FMIR=`sed '/^$/d' $DUMP | head -n1 | awk '{print$2}'`;     # Reset 2017-06-28 16:54:03
    }
    
    # Get Fastest Slackware Mirror for Repository
    fasm ()
    {
    if [[ ! $1 ]]; then 
    echo -e $fus;     # fasm()  Independent   2017-06-27 22:36:55                  
    return 0;
    fi
    
    # Check the Repository      2017-06-15 00:45:36
    if [[ ! ${FUNCNAME[1]} || ${FUNCNAME[1]} =~ ^(main|source)$ ]]; then   # Sourcing (,|source) <file>     2017-06-29 23:19:54     Functioning Independently
        eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
        [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
        DISTROS+=" sbo";                                # 2017-06-19 23:44:55
        [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
        bad $* || return $?         # fasm()  Independent   2017-06-26 13:36:55
    fi
    
    dbg=${dfl:-0};                    # fasm()  Independent   2017-06-26 13:36:55
    # Introduce Directory Area TED in /tmp                  2017-06-15 17:27:27
    if [[ ! $RAW ]]; then   TED=${FUNCNAME[1]};
        [[ -d /tmp/${TED:=fasm} && -w /tmp/$TED ]] || mkdir /tmp/$TED || mkdir /tmp/$TED${SECONDS:0:-2}    # Tags the nearest 100 secs of Up Time
    fi
    RAW=/tmp/$TED/$1.lst; echo -n > $RAW;                     # Initialise.   2017-06-15 17:42:11
    ((dbg)) && echo -e "Raw Output:\t$RAW\nSorted Output:\t$DUMP";
    
    # Truncate Mirror List at Slackware Current
    readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);
    ((${#f[*]})) || { echo Empty Mirror File\!; return 3; }
    
    # Isolate Links
    # Array f now contains Relevant Section of Mirror File
    # Process f to set up Array of Mirrors 'may': http or ftp Protocol Links.
    unset may; for l in "${f[@]}"; do [[ $l =~ ^$hash($proto) ]] && may+=(${BASH_REMATCH[1]}); done    # Array Correction  2017-06-13 14:26:06     & FTP     2017-06-09 00:32:14
    
    ((dbg)) && echo Links=${#may[*]};   # of Mirror Links
    
    ## Vars
    DUMP=/tmp/.fmr.tmp
    
    # Avoid Duplicated Effort in case of Slackwar/Slackwarepatches
    if [[ $SMIR  &&  $1 =~ slackware ]]; then   FNIR=$SMIR;
        ((dbg)) && echo FMIR=$FMIR;
    else    fam;
        # Check there is a Fastest Mirror Found.
        [[ $FMIR ]] || fam  rev;    # Rerun using Eliminated if Any
        [[ $FMIR ]] || { eval echo -e $fsm; return 8; }     # All Mirrors u/s
        # Show time aassociated with Fastest Mirror (debug option)
        ((dbg)) && echo FMIR=$(grep $FMIR $RAW | cut -d " " -f2-);     # Updated to allow for own directory in /tmp unsing global RAW  2017-06-16 18:11:42
        [[ $1 =~ slackware ]] && SMIR=$FMIR
    fi    
    
    # Set the Mirror
    
        # COMMENT OUT ALL Others
    sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
    
        # UNCOOMMENT FASTEST    JUST ONCE!
    sudo sed -i "0,\%^\s*#\s*$FMIR%s??$FMIR?" /etc/usm/mirrors-$1.txt
    
    # Internal Error? Check that there is one Unblocked Mirror
    e=$(grep -E "^\s*$proto" /etc/usm/mirrors-$1.txt);    # 2017-06-11 23:49:14
    m=$(grep -Ec "^\s*$proto" /etc/usm/mirrors-$1.txt);   # 2017-06-11 23:49:14
    
    if [[ m -ne 1 ]]; then echo Internal Error\!; echo "$e"; return 4; fi
    echo Done!; echo $1 mirror set to: "$e";                  # 2017-06-11 23:52:39
    }
    sesm ()
    # Set the Slackware Miirors for All usm Repos
    {
    if [[ ! $1  ||  $1 != all ]]; then 
    echo -e $sus;
    return 0;
    fi
    # Reset Global [Switch] Varables                    2017-06-15 17:14:10
    SMIR="";    # Slackware duplication avoidance switch
    RAW="";     # Raw Output File
    sret="";    # Uniqu Global only used by sesm()      2017-07-20 00:38:14
    # Get Distros
    eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
    [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 5; }
    DISTROS+=" sbo";                                # 2017-06-19 23:44:55
    bad $* || return $?;
    for r in $DISTROS; do echo; echo ${r^^}; sret=""; fasm $r $dfl || [[ ${sret:=$?} -eq 8 ]] || return $sret; done    # sret 2017-07-20 00:38:14   dfl 2017-06-25 15:02:34
    }
    sesm $*
    
  • Script to Set Alternative Fastest Mirror (aka safm.sh)

    Code: Select all

    #!/bin/bash
    # safm.sh   Set Alternative Fast Mirror for Repository by Bogomips  2017-07-02 19:29:46
    # Last Update:  2017-07-12 12:59:50     Check if Raw Output from sesm/fasm exists     
    # Internal Reference:   usm/safm_040717.sh
    # masm.sh   Manually set Slackware Mirror by Bogomips
    # Last Update:  
    # 2017-07-11 13:39:16   bad() added for processing of Command Line Exclusion URLs
    # 2017-07-04 13:07:16   Display Current Mirror followed by Heading
    # 2017-06-19 23:44:55   Include 'sbo' as Repository
    masm ()
    {
    if [[ ! $2 ]]; then 
    echo -e "Argument usage:\t\t<Repository>\t\t<Mirror URL>";
    urn 0;
    fi
    # Check the Protocol
    [[ $2 =~ ^(http|ftp):// ]] || { echo URL Error: Neither http nor ftp.; return 1; }
    # Check the Repository
    eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
    [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
    DISTROS+=" sbo";                                # 2017-06-19 23:44:55
    [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
    # Match the URL
    m=$(grep -c "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt);     # of Matches
    ! ((m)) && { echo \Error! No matching Mirror found.; return 3; }
    url=$2;
    # Exact Matches? Also check if Single Match is an Exact Match   2017-06-16 01:00:01
    # Provide for Missing Trailing Slash        2017-06-17 15:50:45
    n=$(grep -c "\s*#\?\s*$2\s*$" /etc/usm/mirrors-$1.txt); # More Exactly Stipulated   2017-06-16 16:57:49
    # Two Part test caters for exact match not having trailing /.   #  2017-06-18 14:57:55
    ! ((n)) &&  n=$(grep -c "\s*#\?\s*${2%\/}\/\s*$" /etc/usm/mirrors-$1.txt); # More Exactly # No Exact Match
    if ! ((n)); then    w=$(grep "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt | sed s/^\s*#*\s*//)
        echo Partial Match found. Select a Mirror or Enter 0 to quit.; select p in $w; do break; done
        [[ $p ]] || return 4;
        url=$p;     # URL confirmed to exactly match.
    fi
    # If more than one Exact Match, first one will be used.
    # Block All Mirrors
    sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
    # Unblock Selected  Just Once
    sudo sed -i "0,\%^\s*#\s*$url%s??$url?" /etc/usm/mirrors-$1.txt
    echo Done!; echo $1 mirror set to: $(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);             # Providing more accurate information  2017-06-17 15:46:39
    }
    kpv ()
    {
    ## Verification by Key Press		2015-02-12 00:11:36 
    local nu; local k;
        while (( 1 ))
        do
          read -s -n1 -p "$1? [Y/n]" k
          case $k in
          "$nu"	)	echo ""; return 0;;
          [yY]	)	echo ""; return 0;;
          [nN]	)	echo ""; return 1;;
    	*	)  echo $'\n'"Invalid Key '$k'"
          esac
        done
    }
    # Constants
    proto="(http|ftp)://[^[:space:]]+";
    hash="[[:space:]]*#?[[:space:]]*"
    # Assoc Arrays to be Global
    unset allm; declare -A allm;    # Used to Validate URL
    unset bay; declare -A bay;      # Used to Skip testing of URL
    # Function bad()
    # Ascertains if a debug option was defaulted, and sets debug toggle accordingly.
    
    # Exclusion from Testing
    #   Cmd Line URLs
    # Checks Protocols of Cmd Line URLs
    # Checks Relevance of Cmd Line URLs (corresponds to entry in 'mirrors-<repo>.txt')
    # Lists them out.
    
    # Exclusion from Testing
    # File ('.usm/badmirrors.txt' similar format to 'mirrors-<repo>.txt' files)  URLs
    # Option to Proceed if no URLs found in file.
    # Checks Relevance of Cmd Line URLs (correspond to entry in 'mirrors-<repo>.txt'?)
    # List irrelevant URLs found in file together with containing line in file.
    # Option to Proceed if irrelevant URLs found in file.(not in 'mirrors-<repo>.txt')
    bad ()
    {
    err="Error! "
    bm=("Mirror Parameter neither http nor ftp:" "Command Line URL not found in Mirrors' List:");
    # Command Line      2017-06-25 15:01:32
    #   Debug Option?
    dfl=""; [[ $2 =~ ^[0-9]+$ ]] && { dfl=$2; shift; }
    shift;
    
    # Split Cmd Line URLs into pass 'pay' and fail 'fay' categories.
    unset pay fay ret; [[ $* ]] && echo;                    # No Cmd Line URLs
    for l in $*; do if [[ $l =~ ^$proto ]]; then    pay+=($l);    else    fay+=($l); fi done
    
    # Announce Erronous Mirrors
    if [[ -v fay ]]; then ret=6; echo $err${bm[ret-6]}; 
        for l in ${fay[*]}; do echo $l; done
    fi
    
    # Check Cmd Line URL for Relevance
    
    #       Array allm[*] populated with URLs from 'mirrors-<repo>.txt' Time (0.114")
    for r in $DISTROS; do 
        readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$r.txt);
        for l in "${f[@]}"; do [[ $l =~ ^$hash($proto) ]] && allm[${BASH_REMATCH[1]%/}]=; done
    #    for l in "${f[@]}"; do [[ $l =~ ^$hash((http|ftp).*) ]] && allm[${BASH_REMATCH[1]%/}]=; done
    done    
    
    # Assoc Array 'allm' of All Mirrors now Set
    
    for u in ${pay[*]}; do if [[ ! -v allm[${u%/}] ]]; then [[ ret++ -lt 7 ]] && { ret=7; echo $err${bm[ret-6]}; }
        echo $u; fi
    done
    ((ret)) && return $ret;             # Irrelevant URL Error Return.
    
    # Announce Cmd Line URLs
    if ((${#pay[*]})); then    echo Exclusion URL Specified on Command Line:;
        for u in ${pay[*]}; do bay[${u%/}]= ; echo $u; done
    fi
    # Keep Count of Cmd Line URLs
    ucmd=${#pay[*]}; unset ufle umge
    
    # Call from safm?                           2017-07-11 13:39:16
    [[ ${FUNCNAME[1]} == safm ]] && return 0;
    
    # Check for file: '.usm/badmirrors.txt'
    [[ -f  .usm/badmirrors.txt ]] || { echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=0\tMerged(Unique) URLs=${#bay[*]}"; return 0; }
    
    mc=$(grep -Ec "^$hash$proto" .usm/badmirrors.txt);    # Mirror Count
    if ! ((mc)); then echo "No URL found in File '.usm/badmirrors.txt'";
        kpv Proceed || return 10; return 0;
    fi
    # Keep Count of File URLs
    ufle=$mc;
    
    # Validate the URLs in File
    #   Read URLs into Work Array
    readarray -t way < <(grep -E "^$hash$proto" .usm/badmirrors.txt)
    # readarray -t way < <(grep -E "^\s*#*\s*$proto" .usm/badmirrors.txt)
    [[ mc -ne ${#way[*]} ]] && { echo -e "Internal Error! grep/bash count differ: mc=$mc\t\${#way[*]}=${#way[*]}"; return 11; };
    
    # Relevance Check for File URLs
    unset fay;          # Fail Array
    for w in "${way[@]}";
    do 
        [[ $w =~ ^$hash($proto) ]] || { echo "Internal Error! grep/bash RE clash: w='$w'"; return 12; }
        u=${BASH_REMATCH[1]%/};         # Isolated URL
        if [[ ! -v allm[$u] ]]; then    [[ -v fay ]] || { ret=12; echo $err${bm[1]/     Command Line/File}; }
            fay+=($u); [[ $u == $w ]] && echo $u || echo $u$'\n'$w; echo;
        else
            bay[$u]=;
        fi
    done
    ((ret)) && { kpv Proceed || return $ret; }
    
    # Keep Count of Unique URLs
    umge=${#bay[*]}
    ((ucmd+ufle)) && echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=$ufle\tMerged(Unique) URLs=$umge"
    # "Cmd Line URLs=$ucmd\tFile URLs=$ufle\t\tMerged(Unique) URLs=$umge"
    return 0;
    }
    safm ()
    {
    if [[ ! $1 ]]; then 
    echo -e "Argument usage:\t\t<Repository>\t\t[<# of Mirrors to Display (default=6)>]";
    return 0;
    fi
    # Check the Repository
    eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
    [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
    DISTROS+=" sbo";                                # 2017-06-19 23:44:55
    [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
    
    # Look for Command Line Exclusion URLs (fixing default in the process)  2017-07-11 14:51:46
    bad $* || return $?         # fasm()  Independent   2017-06-26 13:36:55
    
    # Get Relevant Files: Output of either sesm or fasm in /tmp
    inits="sesm main source fasm"; unset way;   # Initialise    2017-07-12 12:51:42
    readarray -t way < <(for d in $inits; do [[ -f /tmp/$d/$1.lst ]] && cat /tmp/$d/$1.lst ; done | sort -k3  | cut -d\  -f2-)            # Work Array
    
    # Check if Raw Output from sesm/fasm exists     2017-07-12 12:59:50
    if [[ ! $way ]]; then   echo; echo -n "$err";
        echo -e "Raw Timings for Fastest Mirror Settings mot Found.\n\nPlease run either script to set slackware mirrors (aka sesm.sh): bash sesm.sh all\nOr script to set fastest mirror for repository (aka fasm.sh): bash fasm $1";
        return 8;
    fi
    
    unset bay; declare -A bay; unset uny                      # Filter Array; Unique Array
    # Add Current Mirror to Filter                      2017-07-03 15:00:32
    [[ $(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt) =~ $proto ]] || return 3;    # No current mirror!
    bay[${BASH_REMATCH%/}]=;    # Subscript for Current Mirror  2017-07-03 15:00:32
    # Display Current Mirror                            2017-07-04 13:07:16
    echo ; echo Current Mirror: $BASH_REMATCH; echo Alternative Mirrors;
    # Filter with Trailing Slash Removed                2017-07-03 15:00:32
    for w in "${way[@]}"; do u=${w% *}; [[ -v bay[${u%/}] ]] && continue; bay[${u%/}]=; uny+=("$w"); done
    # 'Select' Array    <-  Unique Array Slice
    say=("${uny[@]:0:${dfl:-6}}")       # bad() also picks up default for Slice Size    2017-07-11 14:56:32
    # say=("${uny[@]:0:${2:-6}}")
    while ((${#say[*]})); 
    do
        select  v in "${say[@]}"; 
        do 
            [[ $v ]] || continue; unset say[$REPLY-1]; say=("${say[@]}");   # Shrink Array  
            masm $1 ${v% *} || return $?; break; 
        done
        kpv "Another Alternative" || break;
    done
    ((${#say[*]})) || echo -n "Choices Exhausted! ";
    echo Terminating.
    }
    safm $*
    
Testing of the mirrors takes around 4 minutes, but there is nothing to prevent multitasking. There is also the added bonus, as shown above, of being able to push through the usm update come what may (within reason of course). Scripts use sudo to update the mirrors, but if prefer not to, then edit out sudo commands and run as root. Also may wish to take security copy of mirror files: /etc/usm/mirrors-*.txt

At this point no need for any further action, unless there is worry about bandwidth, or one wishes to accomplish the testing and the usm update in series, in which cast the following section on tuning the testing would be of interest.

Tuning the Testing

Untuned the testing of mirrors takes around 3' 40" (See last code block of this post). However this time can be reduced by: (Please refer to Exclusion File of URLs here viewtopic.php?f=39&t=7000&sid=5681d83b3 ... 54a#p55999)
  • Description of Stages
    1. Excluding Mirrors on a Geographical Basis
      See Geographical Exclusion
    2. Excluding Mirrors on a Worst Mirror Basis
  • Stages of Tuning (Example)
      1. Create directory for exclusion file of URLs

        Code: Select all

        mkdir  .usm
      2. Using a text editor paste together a .usm/badmirrors.txt file from the mirror.txt files. Example Excerpt:

        Code: Select all

        #----------------------------------------------------------------
        # Slackware64-14.1
        #----------------------------------------------------------------
        # AUSTRALIA (AU)
        # ftp://ftp.cc.swin.edu.au/slackware/
        # http://ftp.cc.swin.edu.au/slackware/
        # ftp://ftp.iinet.net.au/pub/slackware/
        # http://ftp.iinet.net.au/pub/slackware/
        # ftp://mirror.aarnet.edu.au/pub/slackware/
        # http://mirror.aarnet.edu.au/pub/slackware/
        # ftp://mirror.as24220.net/pub/slackware/
        # http://mirror.as24220.net/pub/slackware/
        
    1. Following a Stage 1 Run of the Scripts, append 30 Worst Slackware Mirrors to badmirrors.txt, using script badm.sh:
      • Invocation:

        Code: Select all

        sh badm.sh 30 slackware >> .usm/badmirrors.txt
      • Excerpt from badmirrors.txt Appendage

        Code: Select all

        #-------- 30 Worst Mirrors ---------------SLACKWARE--------Mon Jul  3 13:33:55 BST 2017
        #
        ftp://ftp.linux.org.tr/slackware/
        ftp://mirror.cs.princeton.edu/pub/mirrors/slackware/
        ftp://mirror.its.dal.ca/slackware/
        ftp://spout.ussg.indiana.edu/linux/slackware/
        ftp://mirror.csclub.uwaterloo.ca/slackware/
        ftp://mirrors.slackware.com:/slackware/
        ftp://ftp.cc.uoc.gr/mirrors/linux/slackware/
        ftp://mirrors.us.kernel.org/slackware/
        ftp://mirrors.xmission.com/slackware/
        http://darkstar.ist.utl.pt/pub/slackware/
        ftp://teewurst.cc.columbia.edu/pub/linux/slackware/
        
    2. Following a Stage 2 Run of the Scripts, append 20 Worst Slackware Mirrors to badmirrors.txt, using script badm.sh:
      • Invocation:

        Code: Select all

        badm.sh 20 slackware >> .usm/badmirrors.txt 
      • Excerpt from badmirrors.txt Appendage:

        Code: Select all

        #-------- 20 Worst Mirrors ---------------SLACKWARE--------Tue Jul  4 12:57:26 BST 2017
        #
        ftp://perkons.linux.edu.lv/mirrors/ftp.slackware.com/
        ftp://mirror.switch.ch/mirror/slackware/
        ftp://slackware.mirrors.tds.net/pub/slackware/
        ftp://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/
        ftp://mirrors.unixsol.org/slackware/
        
    3. Following a Stage 3 Run of the Scripts, append 3 Worst Salix Mirrors to badmirrors.txt, using script badm.sh:
      • Invocation

        Code: Select all

        badm.sh 3 salix >> .usm/badmirrors.txt
      • Excerpt from badmirrors.txt Appendage:

        Code: Select all

        #-------- 3 Worst Mirrors --------------------SALIX--------Wed Jul  5 14:48:14 BST 2017
        #
        http://download.salixos.org
        http://salix.enialis.net
        http://salix.hostingxtreme.com
    4. Repeat Step 4.
      • Repeat Step 4.
    5. badmirrors.txt finally ends with

      Code: Select all

      #-------- 3 Worst Mirrors --------------------SALIX--------Wed Jul  5 14:48:14 BST 2017
      #
      http://download.salixos.org
      http://salix.enialis.net
      http://salix.hostingxtreme.com
      --
      #-------- 3 Worst Mirrors --------------------SALIX--------Thu Jul  6 15:12:02 BST 2017
      #
      ftp://ftp.gtlib.gatech.edu/pub/salixos
      ftp://mirrors.xmission.com/salix
      http://www.gtlib.gatech.edu/pub/salixos
      --
      #-------- 3 Worst Mirrors --------------------SALIX--------Fri Jul  7 18:53:39 BST 2017
      #
      ftp://mirror.its.dal.ca/salix
      ftp://ftp.heanet.ie/pub/salix
      ftp://ftp.cc.uoc.gr/mirrors/linux/salix
      
    6. Run of under 40 seconds now a possibility:

      Code: Select all

      guest@porteus:~$ bash  sesm.sh all 
      
      Cmd Line URLs=0         File (.usm/badmirrors.txt) URLs=93      Merged(Unique) URLs=93
      
      SLACKWARE
      Testing ftp://ftp.fu-berlin.de/unix/linux/slackware/ 0.947702
      Mirrors=152             Processed=43            Remaining=109
      Testing ftp://ftp.nluug.nl/vol/4/slackware/ 0.411109
      Mirrors=152             Processed=73            Remaining=79
      Testing http://z-ftp.wcss.wroc.pl/pub/linux/slackware/ 0.144879
      Mirrors=152             Processed=91            Remaining=61
      Testing http://mirrors.kingrst.com/slackware/ Fail
      Mirrors=152             Processed=136           Remaining=16
      Done!
      slackware mirror set to: http://mirror.ovh.net/mirrors/ftp.slackware.com/
      
      SLACKWAREPATCHES
      Done!
      slackwarepatches mirror set to: http://mirror.ovh.net/mirrors/ftp.slackware.com/
      
      SLACKY
      Done!
      slacky mirror set to: http://repository.slacky.eu/
      
      SALIX
      Testing ftp://ftp.nluug.nl/pub/os/Linux/distr/salix 0.597785
      Mirrors=28              Processed=19            Remaining=9
      Done!
      salix mirror set to: http://ftp.nux.ipb.pt/dists/salix
      
      ALIEN
      Done!
      alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
      
      PONCE
      Done!
      ponce mirror set to: http://ponce.cc/slackware
      
      SLACKONLY
      Done!
      slackonly mirror set to: http://packages.slackonly.com/pub/packages
      
      SBO
      Done!
      sbo mirror set to: http://slackbuilds.org/slackbuilds
      
      real    0m38.200s
      user    0m1.760s
      sys     0m1.247s
      
    7. Script badm.sh

      Code: Select all

      #!/bin/bash
      # badm.sh   Display n worst mirrors in repo by Bogomips    2017-06-23 14:54:17
      # Requires raw output of script to set fastest usm mirrors (aka sesm.sh)
      # Repo defaults to 'slackware'
      # Arbitrary cutoff points: n<100    &   (# of mirrors - n) > 9
      # Last Update: 2017-06-27 22:11:32      Fixed length Header of 88 chars.
      badm ()
      {
      um="Argument usage:\t< # of Worst Mirrors to Display >\t[Repository(default:slackware)]\nOnly run after script to set fatest usm mirrors (aka sesm.sh) has run."
      err="Error! "
      local r q=0;
      let y=1 n=-1
      [[ $1 ]] || { echo -e $um; return 0; }
      [[ $1 =~ ^[0-9]+$ ]] && let n=$1;
      [[ n -gt 100 ]] && let r=y; let y++;
      ((n)) || let r=y; let y++;
      [[ n -lt 0 ]] && let r=y; let y++;    # Non-numeric 1st Argument
      # Default slackware?
      # 2nd Argument: Repo (default: slackware)
      rpo=${2:-slackware};
      #    let z=y;     # Set 2nd Arg error message level
      # Check the Repository
      eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
      [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 9; }
      DISTROS+=" sbo";                                # 2017-06-19 23:44:55
      [[ $DISTROS =~ ([[:space:]]|^)$rpo([[:space:]]|$) ]] || let q=y; let y++;
      # Check non-numeric 2nd Arg
      [[ ! $rpo =~ ^[a-z]+$ && n -lt 0 ]] && q=0;
      # Check n ag mirror count
      #   Get mirror count
      if ! ((${r:=q})); then
          mc=$(sed /Slackware64-current/q  /etc/usm/mirrors-$rpo.txt | grep -Ec  "^\s*#?\s*(http|ftp)");
          # Check if remaining mirros exceed 9
          let rm=mc-n; [[ rm -lt 10 ]]  &&  let r=y; let y++;
          [[ -f /tmp/sesm/$rpo.lst ]] ||  let r=y; let y++;
          if ! ((r)); then    w=""; for j in {0..79}; do w+=-; done   # Dash Line
          h="#${w:0:8} $n Worst Mirrors ${w:0:0}${rpo^^}${w:0:8}$(date)";    # Get Measure
          echo -e "#\n#${w:0:8} $n Worst Mirrors ${w:0:88-${#h}}${rpo^^}${w:0:8}$(date)\n#";
          cut -d" " -f2- /tmp/sesm/$rpo.lst | sort -k2 | cut -d" " -f1 | tail -n$n
          return 0;
          fi
      fi
      # Error Message Output
      ms=("# requested $n > 100" "Requested 0 worst mirrors" "Non-numeric 1st argument:  '$1'" "Repo not found: '$rpo'" "Less than 10 remaining mirrors: $mc-$n=$rm" "/tmp/sesm/$rpo.lst not found. Ensure ${rpo^^} has been set thru fastest usm mirrors script (aka sesm.sh).");
      ((r)) && echo $err${ms[r-1]}
      [[ q -gt r ]] && echo $err${ms[q-1]}
      return ${q:-$r};
      }
      badm $*
      


    All Following Scripts Superseded


    Information and a Script to set the Slackware Mirrors for USM

    Information

    There are 8 mirror files but only 7 distros:

    Code: Select all

    guest@porteus:~$ grep ^DISTROS  /etc/usm/usm.conf
    DISTROS="slackware slackwarepatches slacky salix alien ponce slackonly" 
    Distros with just the One Mirror:

    Code: Select all

    guest@porteus:~$ s="slackware slackwarepatches slacky salix alien ponce slackonly"
    guest@porteus:~$ for r in $s; do [[ $(grep -Ec "\s*#*\s*(http|ftp)" /etc/usm/mirrors-$r.txt) -eq 1 ]] && echo $r; done
    alien
    ponce
    slackonly
    
    Ed, good to know script also works for single mirror distros. (Thanks to Ed_P for testing)

    slackware and slackwarepatches mirrors seem to be almost identical:

    Code: Select all

    guest@porteus:~$ sed /Slackware64-current/q  /etc/usm/mirrors-slackware.txt > s
    guest@porteus:~$ sed /Slackware64-current/q  /etc/usm/mirrors-slackwarepatches.txt > t
    guest@porteus:~$ diff t s
    50c50
    < # http://mirrors.slackware.com/slackware/
    ---
    > http://mirrors.slackware.com/slackware/
    73c73
    < http://ftp.slackware-brasil.com.br/
    ---
    > # http://ftp.slackware-brasil.com.br/
    
    Multi-Mirror Distros:

    Code: Select all

    guest@porteus:~$ t="slackware slackwarepatches slacky salix"
    guest@porteus:~$ for r in $t; do echo $r=$(sed /Slackware64-current/q  /etc/usm/mirrors-$r.txt | grep -Ec "^\s*#*\s*(http|ftp)"); done
    slackware=152
    slackwarepatches=152
    slacky=3
    salix=28
    
    Remember reading that USM uses wget. Wget also supports ftp protocol. Anyway did a check by commenting out http mirror and setting arbitrary ftp mirror:

    Code: Select all

    guest@porteus:~$ sudo sed -i '/^\s*http/s//# http/' /etc/usm/mirrors-salix.txt 
    guest@porteus:~$ sudo sed -i s%^\s*#*\s*ftp://salix%ftp//salix%  /etc/usm/mirrors-salix.txt 
    
    guest@porteus:~$ grep -E "^\s*(http|ftp)" /etc/usm/mirrors-salix.txt
    ftp//salix.mirror.garr.it/mirrors/salix
    
    root@porteus:/home/guest# usm -u salix
     Starting salix database update
    Downloading: vercheck.txt  DONE
    Downloading: CHECKSUMS.md5  DONE
    Downloading: PACKAGES.TXT  DONE
    Downloading: LIBS.TXT.gz  DONE
    Downloading: OPTIFEST.gz  DONE
     salix  database updated.
    
    Show Current Mirror Settings:
    • Paste into a Terminal at the Prompt:

      Code: Select all

      eval $(grep DISTROS= /etc/usm/usm.conf);
      echo -e "\n\033[1mDistro Mirrors\033[0m\n"; for d in $DISTROS; do echo ${d^^}; echo -n Set:; grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$d.txt; echo $(sed /Slackware64-current/q  /etc/usm/mirrors-$d.txt | grep -Ec  "^\s*#\s*(http|ftp)" ) Commented Out; echo; done
      
    • Current Mirror Settings

      Code: Select all

      Distro Mirrors
      
      SLACKWARE
      Set:ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
      151 Commented Out
      
      SLACKWAREPATCHES
      Set:ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
      151 Commented Out
      
      SLACKY
      Set:http://slack.isper.sk/pub
      2 Commented Out
      
      SALIX
      Set:http://ftp.belnet.be/salixos.org
      27 Commented Out
      
      ALIEN
      Set:http://bear.alienbase.nl/mirrors/people/alien/sbrepos
      0 Commented Out
      
      PONCE
      Set:http://ponce.cc/slackware
      0 Commented Out
      
      SLACKONLY
      Set:http://packages.slackonly.com/pub/packages
      0 Commented Out
      
      Remember to save the output you get, just in case.
    Setting the Mirrors

    Advisable to take a backup copy before running the script:

    Code: Select all

    cp -a /etc/usm . 
    Will refer to script to set the slackware mirrors as sesm.sh after the name of the bash function invoked by the script, However feel free to give it the most appropriate name for yourself.

    Script Details
    • If there is a problem with sudo, edit out the sudo commands and run script as root, or in a root terminal.
    • If launching the script from a terminal, it has to be invoked with bash, otherwise

      Code: Select all

      guest@porteus:~$ sh sesm.sh 
      sesm.sh: line 63: syntax error near unexpected token `<'
      sesm.sh: line 63: `readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);'
    • Example of Invocation using script fasm.sh to set fastest slackware mirror for a repo
      • Create Script

        Code: Select all

        cp /Path/to/sesm.sh  ,
        sed "s/\s*sesm\s*().*/fasm \$*/;T;q" sesm.sh > fasm.sh
      • Script Invocation

        Code: Select all

        guest@porteus:~$ sh fasm.sh slacky
        fasm.sh: line 63: syntax error near unexpected token `<'
        fasm.sh: line 63: `readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);'
        
        guest@porteus:~$ bash fasm.sh slacky
        Done!
        slacky mirror set to: http://slack.isper.sk/pub
        
    • Running script in a terminal presents no problem,
      • Script can either be pasted into a terminal at the prompt or sourced:

        Code: Select all

        source  /Path/to/sesm.sh
      • Thereafter invoked with the bash function (in the example the function sesm is being timed as well):

        Code: Select all

        guest@porteus:~$ time sesm  all
        
        SLACKWARE
        Testing ftp://ftp.cc.swin.edu.au/slackware/ 3.622269
        Mirrors=152             Processed=3             Remaining=149
        Testing http://ftp.iinet.net.au/pub/slackware/ 0.824413
        Mirrors=152             Processed=6             Remaining=146
        Testing http://mirror.as24220.net/pub/slackware/ 4.001222
        Mirrors=152             Processed=10            Remaining=142
        Testing http://mirror.primusdatacentre.com.au/slackware/ 4.000221
        Mirrors=152             Processed=13            Remaining=139
        Testing http://ftp.slackware.at/data/ 4.000346
        Mirrors=152             Processed=15            Remaining=137
        Testing ftp://mirror.datacenter.by/pub/slackware/ 1.198030
        Mirrors=152             Processed=18            Remaining=134
        Testing ftp://mirror.csclub.uwaterloo.ca/slackware/ 1.680054
        Mirrors=152             Processed=24            Remaining=128
        Testing ftp://mirrors.ucr.ac.cr/slackware/pub/slackware/ 3.282709
        Mirrors=152             Processed=31            Remaining=121
        Testing ftp://nephtys.lip6.fr/pub/linux/distributions/slackware/ 2.441583
        Mirrors=152             Processed=41            Remaining=111
        Testing ftp://ftp.cc.uoc.gr/mirrors/linux/slackware/ 1.892984
        Mirrors=152             Processed=52            Remaining=100
        Testing http://kambing.ui.ac.id/slackware/ 0.607585
        Mirrors=152             Processed=60            Remaining=92
        Testing ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/ 3.999801
        Mirrors=152             Processed=66            Remaining=86
        Testing ftp://riksun.riken.go.jp/Linux/slackware/ 3.921242
        Mirrors=152             Processed=70            Remaining=82
        Testing ftp://ftp.man.szczecin.pl/pub/Linux/slackware/ 4.001278
        Mirrors=152             Processed=80            Remaining=72
        Testing ftp://z-ftp.wcss.wroc.pl/pub/linux/slackware/ 0.695328
        Mirrors=152             Processed=90            Remaining=62
        Testing http://darkstar.ist.utl.pt/pub/slackware/ 4.001580
        Mirrors=152             Processed=93            Remaining=59
        Testing http://mirror2.etf.bg.ac.rs/slackware/ 4.000899
        Mirrors=152             Processed=98            Remaining=54
        Testing ftp://ftp.wa.co.za/pub/slackware/ 2.569787
        Mirrors=152             Processed=101           Remaining=51
        Testing http://slackware.mirror.ac.za/ 2.291520
        Mirrors=152             Processed=104           Remaining=48
        Testing ftp://ftp.isu.edu.tw/pub/Linux/Slackware/ 3.999778
        Mirrors=152             Processed=111           Remaining=41
        Testing http://ftp.twaren.net/Linux/Slackware/ 0.750657
        Mirrors=152             Processed=114           Remaining=38
        Testing ftp://carroll.aset.psu.edu/pub/linux/distributions/slackware/ 4.001532
        Mirrors=152             Processed=123           Remaining=29
        Testing ftp://ftp.gtlib.gatech.edu/nv/ao2/lxmirror/ftp.slackware.com/ 1.680286
        Mirrors=152             Processed=125           Remaining=27
        Testing http://marmot.tn.utexas.edu/slackware/ 0.528524
        Mirrors=152             Processed=131           Remaining=21
        Testing http://mirrors.kingrst.com/slackware/ 0.456996
        Mirrors=152             Processed=136           Remaining=16
        Testing http://slackware.mirrorcatalogs.com/ 0.042592
        Mirrors=152             Processed=143           Remaining=9
        Testing http://slackware.virginmedia.com/ 3.503471
        Mirrors=152             Processed=148           Remaining=4
        Done!
        slackware mirror set to: ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
        
        SLACKWAREPATCHES
        Done!
        slackwarepatches mirror set to: ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
        
        SLACKY
        Done!
        slacky mirror set to: http://slack.isper.sk/pub
        
        SALIX
        Testing http://download.salixos.org Fail
        Mirrors=28              Processed=11            Remaining=17
        Testing ftp://salix.mirror.garr.it/mirrors/salix 1.118754
        Mirrors=28              Processed=17            Remaining=11
        Testing ftp://mirrors.xmission.com/salix 1.941643
        Mirrors=28              Processed=25            Remaining=3
        Done!
        salix mirror set to: http://ftp.belnet.be/salixos.org
        
        ALIEN
        Done!
        alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
        
        PONCE
        Done!
        ponce mirror set to: http://ponce.cc/slackware
        
        SLACKONLY
        Done!
        slackonly mirror set to: http://packages.slackonly.com/pub/packages
        
        real    3m40.491s
        user    0m3.155s
        sys     0m1.393s
        
    Script to set the Slackware Mirrors for USM
    Follows in adjacent Post

    SUMMARY

    <> used to denote fixed format (code) block.

    Script to set the Slackware Mirrors for USM Referred to here as sesm.sh, but can be given any convenient name of one's choosing:<>

    sesm invoked with argument all, If 1st argument not all, this will be taken as request to show usage parameters. If problem with sudo, edit out sudo commands, then run as root. Also, to run the script in a shell, the bash shell has to be invoked:<>

    Prior to Running Script recommend:
    • Back Up<>
    • List current status of all mirrors
      • Status of All Mirrors script sam.sh:<>
      • Status Output (might pay to keep a note of current settings):<>
    Mirrors can be restored from backup copy. In a root terminal:<>

    Fastest Mirror for Single Repository
    • There is also the option of independently setting the fastest mirror for a repository thru script fasm.sh: <>
    • Again, has to be invoked via bash shell:<>
    Independent Checking
    • Listings
      • List All Mirrors of Repository
        • <>
        • <>
      • Check the Repository Mirror
        • Script crm.sh<>
        • <>
    • Timintgs
      • Directories for Timings Files. Directory holding raw output files will be made in /tmp. Name of directory dictated by function to find fastest mirror of a repository, fasm. If invoked by
        • sesm files will be created in /tmp/sesm
        • the shell, as a script, calling function is main, files created in /tmp/main
        • none, and run directly as a function in terminal, files will be created under /tmp/fasm.
        ,
      • Raw Output. These files all named <repository>.lst:<>
      • Output Refined<>
    TIMINGS
    • Made minutes apart<>
    • Made minutes apart<>
    • Made several hours later:<>
    So, ability to set mirrors manually obvious. Put together script to manually set the mirror:
    • masm.sh<>
    • Invocation<>
    Epilog
    Last edited by Bogomips on 25 Jul 2017, 23:00, edited 10 times in total.
    Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
    NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

    Bogomips
    Full of knowledge
    Full of knowledge
    Posts: 2564
    Joined: 25 Jun 2014, 15:21
    Distribution: 3.2.2 Cinnamon & KDE5
    Location: London

    Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

    Post#2 by Bogomips » 15 Jun 2017, 12:10

    Script to set the Slackware Mirrors for USM

    Referred to here as sesm.sh, but can be given any convenient name of one's choosing:

    Code: Select all

    #!/bin/bash
    # sesm.sh   Set the Slackware Miirors for usm Repos    Bogomips    2017-06-13 19:33:50
    # fasm.sh   Adaptation by Bogomips to Set Fastest Slackware Repository Mirror   2017-06-07 21:35:10
    # Last Update:   2017-06-16 18:11:42    Corrected to [include own directory] using RAW in Debug Mode
    
    # 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>
    # This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt
    
    # Get Fastest Mirror
    fam() {
    ## get list
    local -n MIRRORS=${1:-may};
    
    ## Number of seconds before the test is considered a failure
    TIMEOUT="4"
    
    ## String to store results in
    RESULTS=""
    # Elapsed Time Check        Output an Update every 5 sec.
    let x=SECONDS;
    
    for ((i=0; i<${#MIRRORS[*]}; i++)) ; do     MIRROR=${MIRRORS[i]};
        let y=SECONDS;
        if [[ y-x -gt 5 && i -gt 0 ]]; then
            tail -n1 $RAW;
            echo -e "Mirrors=${#MIRRORS[*]}\t\tProcessed=$i\t\tRemaining=$((${#MIRRORS[*]}-i))";
            let x=SECONDS;      # Reset
        fi
        echo -n "Testing ${MIRROR} " >> $RAW
     
        URL="${MIRROR}%{FILE}"
    	
    	TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL`
    	
    	if [[ $TIME =~ ^0.000 ]] ; then
    		echo "Fail" >> $RAW;
    	else 
    		echo $TIME >> $RAW
    		RESULTS="${RESULTS}${TIME}\t${MIRROR}\n";
    	fi
    done;
    
    echo -e $RESULTS | sort -n > $DUMP
    FMIR=`sed '/^$/d' $DUMP | head -n1 | awk '{print$2}'`
    }
    
    # Get Fastest Slackware Mirror for Repository
    fasm ()
    {
    if [[ ! $1 ]]; then 
    echo -e "Argument usage:\t\t<Repository>\t\t[<Toggle Debug: 0/1>]";
    return 0;
    fi
    
    # Check the Repository      2017-06-15 00:45:36
    if [[ ${FUNCNAME[1]} != sesm ]]; then   # Functioning Independently
        eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
        [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
        [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
    fi
    
    dbg=${2:-0};
    # Introduce Directory Area TED in /tmp                  2017-06-15 17:27:27
    if [[ ! $RAW ]]; then   TED=${FUNCNAME[1]};
        [[ -d /tmp/${TED:=fasm} && -w /tmp/$TED ]] || mkdir /tmp/$TED || mkdir /tmp/$TED${SECONDS:0:-2}    # Tags the nearest 100 secs of Up Time
    fi
    RAW=/tmp/$TED/$1.lst; echo -n > $RAW;                     # Initialise.   2017-06-15 17:42:11
    ((dbg)) && echo -e "Raw Output:\t$RAW\nSorted Output:\t$DUMP";
    
    # Truncate Mirror List at Slackware Current
    readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);
    ((${#f[*]})) || { echo Empty Mirror File\!; return 3; }
    
    # Isolate Links
    # Array f now contains Relevant Section of Mirror File
    # Process f to set up Array of Mirrors 'may': http or ftp Protocol Links.
    unset may; for l in "${f[@]}"; do [[ $l =~ ^[[:space:]]*#?[[:space:]]*((http|ftp).*) ]] && may+=(${BASH_REMATCH[1]}); done    # Array Correction  2017-06-13 14:26:06     & FTP     2017-06-09 00:32:14
    
    ((dbg)) && echo Links=${#may[*]};   # of Mirror Links
    
    ## Vars
    DUMP=/tmp/.fmr.tmp
    
    # Avoid Duplicated Effort in case of Slackwar/Slackwarepatches
    if [[ $SMIR  &&  $1 =~ slackware ]]; then   FNIR=$SMIR;
        ((dbg)) && echo FMIR=$FMIR;
    else
        # Show time aassociated with Fastest Mirror (debug option)
        fam; ((dbg)) && echo FMIR=$(grep $FMIR $RAW | cut -d " " -f2-);     # Updated to allow for own directory in /tmp unsing global RAW  2017-06-16 18:11:42
        [[ $1 =~ slackware ]] && SMIR=$FMIR
    fi    
    
    # Set the Mirror
    
        # COMMENT OUT ALL Others
    sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
    
        # UNCOOMMENT FASTEST    JUST ONCE!
    sudo sed -i "0,\%^\s*#\s*$FMIR%s??$FMIR?" /etc/usm/mirrors-$1.txt
    
    # Internal Error? Check that there is one Unblocked Mirror
    e=$(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);    # 2017-06-11 23:49:14
    m=$(grep -Ec "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);   # 2017-06-11 23:49:14
    
    if [[ m -ne 1 ]]; then echo Internal Error\!; echo "$e"; return 4; fi
    echo Done!; echo $1 mirror set to: "$e";                  # 2017-06-11 23:52:39
    }
    sesm ()
    # Set the Slackware Miirors for All usm Repos
    {
    if [[ ! $1  ||  $1 != all ]]; then 
    echo -e "Argument usage:\t\tall\t[<Toggle Debug: 0/1>]";
    return 0;
    fi
    # Reset Global [Switch] Varables                    2017-06-15 17:14:10
    SMIR="";    # Slackware duplication avoidance switch
    RAW="";     # Raw Output File
    # Get Distros
    eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
    [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 5; }
    
    for d in $DISTROS; do echo; echo ${d^^}; fasm $d $2 || return $?; done
    }
    sesm $*
    
    sesm invoked with argument all, If 1st argument not all, this will be taken as request to show usage parameters. If problem with sudo, edit out sudo commands, then run as root. Also, to run the script in a shell, the bash shell has to be invoked:

    Code: Select all

    uest@porteus:~$ bash sesm.sh all
    
    SLACKWARE
    Testing ftp://ftp.cc.swin.edu.au/slackware/ 4.000086
    Mirrors=152             Processed=3             Remaining=149
    Testing ftp://mirror.aarnet.edu.au/pub/slackware/ 0.246358
    Mirrors=152             Processed=7             Remaining=145
    Testing ftp://mirror.internode.on.net/.pub2/slackware/ 3.999666
    Mirrors=152             Processed=11            Remaining=141
    Testing ftp://ftp.slackware.at/ 4.001597
    Mirrors=152             Processed=14            Remaining=138
    Testing ftp://gd.tuwien.ac.at/opsys/linux/freesoftware.com/ 4.001687
    Mirrors=152             Processed=16            Remaining=136
    Testing http://ftp.slackware-brasil.com.br/ 0.552316
    Mirrors=152             Processed=21            Remaining=131
    Testing http://mirror.bjtu.edu.cn/slackware/ 0.746992
    Mirrors=152             Processed=28            Remaining=124
    Testing ftp://mirrors.ucr.ac.cr/slackware/pub/slackware/ 3.295933
    Mirrors=152             Processed=31            Remaining=121
    Testing ftp://nephtys.lip6.fr/pub/linux/distributions/slackware/ 0.995421
    Mirrors=152             Processed=41            Remaining=111
    Testing ftp://ftp.cc.uoc.gr/mirrors/linux/slackware/ 1.827660
    Mirrors=152             Processed=52            Remaining=100
    Testing http://kambing.ui.ac.id/slackware/ 3.999738
    Mirrors=152             Processed=60            Remaining=92
    Testing ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/ 3.999632
    Mirrors=152             Processed=66            Remaining=86
    Testing ftp://riksun.riken.go.jp/Linux/slackware/ 4.000105
    Mirrors=152             Processed=70            Remaining=82
    Testing ftp://ftp.man.szczecin.pl/pub/Linux/slackware/ 4.000205
    Mirrors=152             Processed=80            Remaining=72
    Testing ftp://z-ftp.wcss.wroc.pl/pub/linux/slackware/ 0.784232
    Mirrors=152             Processed=90            Remaining=62
    Testing http://darkstar.ist.utl.pt/pub/slackware/ 4.000653
    Mirrors=152             Processed=93            Remaining=59
    Testing ftp://mirror2.etf.bg.ac.rs/slackware/ 4.001159
    Mirrors=152             Processed=97            Remaining=55
    Testing ftp://ftp.is.co.za/mirror/ftp.slackware.com/pub/ 3.398824
    Mirrors=152             Processed=99            Remaining=53
    Testing ftp://slackware.mirror.ac.za/ 3.405568
    Mirrors=152             Processed=103           Remaining=49
    Testing ftp://ftp.isu.edu.tw/pub/Linux/Slackware/ 4.000624
    Mirrors=152             Processed=111           Remaining=41
    Testing ftp://ftp.twaren.net/pub/Linux/Slackware/ 4.000165
    Mirrors=152             Processed=113           Remaining=39
    Testing ftp://carroll.aset.psu.edu/pub/linux/distributions/slackware/ 4.001106
    Mirrors=152             Processed=123           Remaining=29
    Testing ftp://ftp.gtlib.gatech.edu/nv/ao2/lxmirror/ftp.slackware.com/ 4.001585
    Mirrors=152             Processed=125           Remaining=27
    Testing http://marmot.tn.utexas.edu/slackware/ 0.383969
    Mirrors=152             Processed=131           Remaining=21
    Testing http://mirrors.kingrst.com/slackware/ 0.457115
    Mirrors=152             Processed=136           Remaining=16
    Testing http://slackbuilds.org/mirror/slackware/ 0.352356
    Mirrors=152             Processed=141           Remaining=11
    Testing ftp://slackware.virginmedia.com/mirrors/ftp.slackware.com/ 3.755941
    Mirrors=152             Processed=147           Remaining=5
    Testing ftp://spout.ussg.indiana.edu/linux/slackware/ 1.785485
    Mirrors=152             Processed=149           Remaining=3
    Done!
    slackware mirror set to: http://slackware.mirrorcatalogs.com/
    
    SLACKWAREPATCHES
    Done!
    slackwarepatches mirror set to: http://slackware.mirrorcatalogs.com/
    
    SLACKY
    Done!
    slacky mirror set to: http://slack.isper.sk/pub
    
    SALIX
    Testing http://download.salixos.org Fail
    Mirrors=28              Processed=11            Remaining=17
    Testing ftp://salix.mirror.garr.it/mirrors/salix 1.051580
    Mirrors=28              Processed=17            Remaining=11
    Testing ftp://ftp.gtlib.gatech.edu/pub/salixos 4.001338
    Mirrors=28              Processed=24            Remaining=4
    Done!
    salix mirror set to: http://ftp.nluug.nl/os/Linux/distr/salix
    
    ALIEN
    Done!
    alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
    
    PONCE
    Done!
    ponce mirror set to: http://ponce.cc/slackware
    
    SLACKONLY
    Done!
    slackonly mirror set to: http://packages.slackonly.com/pub/packages
    Prior to Running Script recommend:
    • Back Up

      Code: Select all

      cp -a /etc/usm/ .
         
    • List current status of all mirrors
      • Status of All Mirrors script sam.sh:

        Code: Select all

        #!/bin/bash
        # sam.sh  Status of all Mirrors by Bogomips  15-6-17
        sam ()
        {
        eval $(grep DISTROS= /etc/usm/usm.conf)
        echo -e "\n\033[1mDistro Mirrors\033[0m\n"; for d in $DISTROS; do echo ${d^^}; echo -n "Mirror: "; grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$d.txt; echo $(sed /Slackware64-current/q  /etc/usm/mirrors-$d.txt | grep -Ec  "^\s*#\s*(http|ftp)" ) Commented Out; echo; done
        }
        sam
        
      • Status Output (might pay to keep a note of current settings):

        Code: Select all

        Distro Mirrors
        
        SLACKWARE
        Set:http://ftp.osuosl.org/.2/slackware/
        151 Commented Out
        
        SLACKWAREPATCHES
        Set:http://ftp.slackware-brasil.com.br/
        151 Commented Out
        
        SLACKY
        Set:http://repository.slacky.eu/
        2 Commented Out
        
        SALIX
        Set:http://salix.hostingxtreme.com
        27 Commented Out
        
        ALIEN
        Set:http://bear.alienbase.nl/mirrors/people/alien/sbrepos
        0 Commented Out
        
        PONCE
        Set:http://ponce.cc/slackware
        0 Commented Out
        
        SLACKONLY
        Set:http://packages.slackonly.com/pub/packages
        0 Commented Out
        
    Should anything go wrong, there is no need for panic, as mirrors can be restored from backup copy. In a root terminal:

    Code: Select all

    cp  -p  usm/mirrors-*.txt   /etc/usm/   
    Fastest Mirror for Single Repository
    • There is also the option of independently setting the fastest mirror for a repository thru script fasm.sh:

      Code: Select all

      cp  -p  /Path/to/sesm.sh   .
      sed  "s/\s*sesm\s*().*/fasm \$*/;T;q"  sesm.sh  >  fasm.sh
      
    • Again, has to be invoked via bash shell:

      Code: Select all

      guest@porteus:~$ bash fasm.sh slacky
      Done!
      slacky mirror set to: http://slack.isper.sk/pub
      
    Independent Checking
    • Listings
      • List All Mirrors of Repository
        • Code: Select all

          r=<Repository>
          sed -En "/Slackware64-current/q;/^\s*#*\s*(http|ftp)\S*$/p"  /etc/usm/mirrors-$r.txt
          
        • Code: Select all

          guest@porteus:~$ r=slacky
          guest@porteus:~$ sed -En "/Slackware64-current/q;/^\s*#*\s*(http|ftp)\S*$/p"  /etc/usm/mirrors-$r.txt
          http://repository.slacky.eu/
          #http://slackware.org.uk/slacky
          #http://slack.isper.sk/pubguest@porteus:~$ ^C
          
          guest@porteus:~$ r=salix
          guest@porteus:~$ sed -En "/Slackware64-current/q;/^\s*#*\s*(http|ftp)\S*$/p"  /etc/usm/mirrors-$r.txt | tail -n3
          #http://mirrors.xmission.com/salix
          http://salix.hostingxtreme.com
          #http://www.gtlib.gatech.edu/pub/salixos
          
          guest@porteus:~$ sed -En "/Slackware64-current/q;/^\s*#*\s*(http|ftp)\S*$/p"  /etc/usm/mirrors-$r.txt | wc -l
          28
          
          guest@porteus:~$ r=slackware
          guest@porteus:~$ sed -En "/Slackware64-current/q;/^\s*#*\s*(http|ftp)\S*$/p"  /etc/usm/mirrors-$r.txt | wc -l
          152
          
      • Check the Repository Mirror
        • Script crm.sh

          Code: Select all

          #!/bin/bash
          # crm.sh   Check Repository Mirror Setting by Bogomips   14-6-17
          # Last Update:  2017-06-14 23:05:37
          crm ()
          {
          if [[ ! $1 ]]; then 
          echo -e "Argument usage:\t\t<Repository>";
          return 0;
          fi
          # Check the Repository
          eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
          [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
          [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
          d=$1; echo ${d^^}; echo -n "Mirror: "; grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$d.txt; echo $(sed /Slackware64-current/q  /etc/usm/mirrors-$d.txt | grep -Ec  "^\s*#\s*(http|ftp)" ) Commented Out;
          }
          crm $*
             
        • Code: Select all

          guest@porteus:~$ source  crm.sh 
          Argument usage:         <Repository>
          
          guest@porteus:~$ crm slackware
          SLACKWARE
          Mirror: http://slackware.mirrorcatalogs.com/
          151 Commented Out
    • Timintgs
      • Directories for Timings Files. Directory holding raw output files will be made in /tmp. Name of directory dictated by function to find fastest mirror of a repository, fasm. If invoked by
        • sesm files will be created in /tmp/sesm
        • the shell, as a script, calling function is main, files created in /tmp/main
        • none, and run directly as a function in terminal, files will be created under /tmp/fasm.
        ,
      • Raw Output. These files all named <repository>.lst:

        Code: Select all

        guest@porteus:~$ ls -l /tmp/sesm/slacky.lst
        -rw-r--r-- 1 guest users 137 Jun 17 17:30 /tmp/sesm/slacky.lst
        guest@porteus:~$ cat  /tmp/sesm/slacky.lst
        Testing http://repository.slacky.eu/ 0.136803
        Testing http://slackware.org.uk/slacky 0.053876
        Testing http://slack.isper.sk/pub 0.152823
        
      • Output Refined

        Code: Select all

        guest@porteus:~$ cut -d" " -f2- /tmp/sesm/salix.lst | sort -k2 | head -n6
        http://ftp.nux.ipb.pt/dists/salix 0.039214
        http://ftp.nluug.nl/os/Linux/distr/salix 0.089937
        http://ftp.belnet.be/salixos.org 0.094682
        http://slackware.org.uk/salix 0.126535
        http://ftp.heanet.ie/pub/salix 0.128548
        http://mirrors.nix.org.ua/linux/salixos 0.138708
    TIMINGS
    • Made minutes apart

      Code: Select all

      guest@porteus:~$ sort -k 3 $g/usm/slackwarepatches.lst | head
      Testing http://slackware.mirrorcatalogs.com/ 0.081814
      Testing http://mirror.nl.leaseweb.net/slackware/ 0.087654
      Testing http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.090165
      Testing http://mirror.ovh.net/mirrors/ftp.slackware.com/ 0.093047
      Testing http://mirror.bytemark.co.uk/slackware/ 0.105195
      Testing http://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ 0.106060
      Testing http://mirrors.dotsrc.org/.disk1/slackware/ 0.106633
      Testing http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.110327
      Testing http://sunsite.informatik.rwth-aachen.de/ftp/pub/comp/Linux/slackware/ 0.110971
      Testing http://ftp.gwdg.de/pub/linux/slackware/ 0.112761
      
    • Made minutes apart

      Code: Select all

      guest@porteus:~$ sort -k 3 $g/usm/sesm/slackware.lst | head
      Testing ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/ 0.038587
      Testing http://slackware.mirrorcatalogs.com/ 0.042592
      Testing http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.088435
      Testing http://mirror.ovh.net/mirrors/ftp.slackware.com/ 0.091196
      Testing http://mirror.nl.leaseweb.net/slackware/ 0.093170
      Testing http://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ 0.097865
      Testing http://ftp.gwdg.de/pub/linux/slackware/ 0.104211
      Testing http://mirrors.dotsrc.org/.disk1/slackware/ 0.110461
      Testing http://sunsite.informatik.rwth-aachen.de/ftp/pub/comp/Linux/slackware/ 0.110465
      Testing http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.112376
      
    • Made several hours later:

      Code: Select all

      guest@porteus:~$ sort -k 3 /tmp/slackware.lst | head
      Testing http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.092668
      Testing http://mirror.ovh.net/mirrors/ftp.slackware.com/ 0.094060
      Testing http://mirror.nl.leaseweb.net/slackware/ 0.095253
      Testing http://ftp.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ 0.101238
      Testing http://ftp.gwdg.de/pub/linux/slackware/ 0.105236
      Testing http://mirrors.dotsrc.org/.disk1/slackware/ 0.110231
      Testing http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.111355
      Testing http://wrz1013.rz.uni-wuerzburg.de/pub/MIRROR/slackware/ 0.114544
      Testing http://sunsite.informatik.rwth-aachen.de/ftp/pub/comp/Linux/slackware/ 0.114701
      Testing http://mirror.bytemark.co.uk/slackware/ 0.124695
      
    Inspection of the timimgs shows a wide discrepancy between those made minutes apart and those made several hours later. For instance, slackware.mirrorcatalogs.com which featured ate the top of the list is nowhere in the top ten, several hours later.. Clearly indicates a dependency on time of day, and also perhaps on prevailing conditions in the Internet.

    So, ability to set mirrors manually obvious. Put together script to manually set the mirror:
    • masm.sh

      Code: Select all

      #!/bin/bash
      # masm.sh   Manually set Slackware Mirror by Bogomips
      # Last Update:  2017-06-18 14:57:55     Cater for exact mirror match not having trailing /.
      masm ()
      {
      if [[ ! $2 ]]; then 
      echo -e "Argument usage:\t\t<Repository>\t\t<Mirror URL>";
      return 0;
      fi
      # Check the Protocol
      [[ $2 =~ ^(http|ftp):// ]] || { echo URL Error: Neither http nor ftp.; return 1; }
      # Check the Repository
      eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
      [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
      [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
      # Match the URL
      m=$(grep -c "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt);     # of Matches
      ! ((m)) && { echo \Error! No matching Mirror found.; return 3; }
      url=$2;
      # Exact Matches? Also check if Single Match is an Exact Match   2017-06-16 01:00:01
      # Provide for Missing Trailing Slash        2017-06-17 15:50:45
      n=$(grep -c "\s*#\?\s*$2\s*$" /etc/usm/mirrors-$1.txt); # More Exactly Stipulated   2017-06-16 16:57:49
      # Two Part test caters for exact match not having trailing /.   #  2017-06-18 14:57:55
      ! ((n)) &&  n=$(grep -c "\s*#\?\s*${2%\/}\/\s*$" /etc/usm/mirrors-$1.txt); # More Exactly # No Exact Match
      if ! ((n)); then    w=$(grep "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt | sed s/^\s*#*\s*//)
          echo Partial Match found. Select a Mirror or Enter 0 to quit.; select p in $w; do break; done
          [[ $p ]] || return 4;
          url=$p;     # URL confirmed to exactly match.
      fi
      # If more than one Exact Match, first one will be used.
      # Block All Mirrors
      sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
      # Unblock Selected  Just Once
      sudo sed -i "0,\%^\s*#\s*$url%s??$url?" /etc/usm/mirrors-$1.txt
      echo Done!; echo $1 mirror set to: $(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);             # Providing more accurate information  2017-06-17 15:46:39
      }
      masm $*
        
    • Invocation

      Code: Select all

      uest@porteus:~$ sh $g/masm.sh
      Argument usage:         <Repository>            <Mirror URL>
      guest@porteus:~$ bash $g/masm.sh
      Argument usage:         <Repository>            <Mirror URL>
      
      guest@porteus:~$ sh $g/masm.sh  slackwarepatches http://slackware.mirrorcatalogs.com
      Done!
      slackwarepatches mirror set to: http://slackware.mirrorcatalogs.com/
      
      guest@porteus:~$ sh $g/masm.sh  slackwarepatches http://mirror.bytemark.co.uk/slackware/Done!
      slackwarepatches mirror set to: http://mirror.bytemark.co.uk/slackware/
      
    Epilog

    This should take most of the guesswork out in regard to which mirror to try, whether it be performance improvement or the need to try a different mirror. As well would be good idea to set the mirrors before embarking on a lot of usm-ing.

    Script has been supplemented here with couple of helper routines, which I found needed to knock up for my requirements. If problem with sudo, run as root all scripts that set mirrors.

    Enjoy!
    Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
    NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

    Bogomips
    Full of knowledge
    Full of knowledge
    Posts: 2564
    Joined: 25 Jun 2014, 15:21
    Distribution: 3.2.2 Cinnamon & KDE5
    Location: London

    [INFO & SCRIPT] Slackware Mirror Settings for USM

    Post#3 by Bogomips » 15 Jun 2017, 12:11

    Enhancements & Updates

    Updates Posted

    Mon Jul 24 17:08:33 UTC 2017: Very very final Enhancement
    • Script to Set the fastest Slackware Mirrors (aka sesm.sh)
    • Script to Set Alternative Fastest Mirror (aka safm.sh)
    Wed Jul 5 00:20:06 UTC 2017: Minor enhancement for safm.sh to show Current Mirror prior to displaying Alternatives.

    Mon Jul 3 23:26:55 UTC 2017: Very Final Enhancement
    • Script to Set Alternative Fastest Mirror safm.sh
    • Script to Manually Set Mirror for a Repository masm.sh can be cut out from safm.sh, which uses it.
    Sat Jul 1 22:39:10 UTC 2017: Clarification of Creation of Exclusions File: badmirrors.txt

    Sat Jul 1 00:14:29 UTC 2017: Final Enhancement (Icing on Cake) where both sesm.sh and fasm.sh enhanced with Command Line Mirror Exclusion List plus Optional Exclusion File of URLs.

    Wed Jun 28 21:19:19 UTC 2017: sesm.sh enhanced; usage message for fasm.sh corrected.

    Tue Jun 27 00:50:36 UTC 2017: both sesm.sh and fasm.sh enhanced with Command Line Mirror Exclusion List.

    Enhancements

    Candle

    Script to Set Alternate Fast Mirror for a Repository, safm.sh, needs to be run in a bash shell, and after one of scripts sesm.sh or fasm.sh (Setting Slackware Mirrors or Fastest Mirror for Repo) has run, This is because safm.sh operates on the raw output generated by these scripts.

    This is logical, as safm.sh has been concieved to resolve issues thrown up by usm with the fastest mirror that has been set. Illustration showing action Interleaved between Two Terminals:
    • USM Update Issue

      Code: Select all

      guest@porteus:~$ time sesm  all http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/ http://mirror.internode.on.net/pub/slackware/            
      
      Exclusion URL Specified on Command Line:
      http://slack.isper.sk/pub
      http://mirror.ovh.net/mirrors/ftp.slackware.com/
      http://slackware.mirrorcatalogs.com/
      http://mirror.internode.on.net/pub/slackware/
      
      All Exclusion URLs:
      Cmd Line URLs=4         File (.usm/badmirrors.txt) URLs=64      Merged(Unique) URLs=67
      
      SLACKWARE
      Testing http://mirrors.ucr.ac.cr/slackware/pub/slackware/ 0.617565
      Mirrors=152             Processed=32            Remaining=120
      ...
      Testing ftp://slackware.mirrors.tds.net/pub/slackware/ 0.691765
      Mirrors=152             Processed=145           Remaining=7
      Done!
      slackware mirror set to: ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
      
      root@porteus:/home/guest# time usm -u all
       Starting slackware database update 
      Downloading: vercheck.txt  DONE
      Downloading: CHECKSUMS.md5  DONE
      Downloading: MANIFEST.bz2  DONE
      Downloading: PACKAGES.TXT  DONE
      Downloading: LIBS.TXT.gz  DONE
       There was a problem downloading the file: 
      real    0m4.158s
      user    0m0.714s
      sys     0m0.750s
      
      guest@porteus:~$ sh crm.sh slackware      # Check Repo Mirror
      SLACKWARE
      Mirror: ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/
      151 Commented Out
      
    • Next Attempt with Alternate Fast Mirror

      Code: Select all

      guest@porteus:~$ bash safm.sh slackware
      1) ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/ 0.037924
      2) http://mirror.nl.leaseweb.net/slackware/ 0.090150
      3) http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.093910
      4) http://mirrors.dotsrc.org/.disk1/slackware/ 0.107793
      5) http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.109383
      6) http://ftp.gwdg.de/pub/linux/slackware/ 0.111483
      #? 2
      http://mirror.nl.leaseweb.net/slackware/ 0.090150 2
      Done!
      slackware mirror set to: http://mirror.nl.leaseweb.net/slackware/
      Another Alternative? [Y/n]
      
      root@porteus:/home/guest# time usm -u all
       Starting slackware database update 
      Downloading: vercheck.txt --> ^C
      rm: cannot remove '/home/guest/p10/Por/tmp64/usm/vercheck.txt': No such file or directory
      
      real    0m17.809s
      user    0m0.531s
      sys     0m0.256s
      
    • Second Alternate Fast Mirror does the trick!

      Code: Select all

      1) ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/ 0.037924
      2) http://ftp.nluug.nl/os/Linux/distr/slackware/ 0.093910
      3) http://mirrors.dotsrc.org/.disk1/slackware/ 0.107793
      4) http://sunsite.icm.edu.pl/packages/linux-slackware/ 0.109383
      5) http://ftp.gwdg.de/pub/linux/slackware/ 0.111483
      #? 3
      http://mirrors.dotsrc.org/.disk1/slackware/ 0.107793 3
      Done!
      slackware mirror set to: http://mirrors.dotsrc.org/.disk1/slackware/
      Another Alternative? [Y/n]
      Terminating.
      
      root@porteus:/home/guest# time usm -u all
       Starting slackware database update 
      ...
      sbo was updated 298 seconds ago. Skipping.
      
      Downloading: extra-deps.txt  DONE
      Downloading: ignore-deps.txt  DONE
      ...
      real    2m22.562s
      user    0m21.694s
      sys     0m5.970s
      
    Setting Alternate Fast Mirror
      • Script safm.sh

        Code: Select all

        #!/bin/bash
        # safm.sh   Set Alternative Fast Mirror for Repository by Bogomips  2017-07-02 19:29:46
        # Last Update:  2017-07-03 21:26:32  
        # Internal Reference:   usm/safm_040717.sh
        # masm.sh   Manually set Slackware Mirror by Bogomips
        # Last Update:  2017-07-04 13:07:16     Display Current Mirror followed by Heading
        # 2017-06-19 23:44:55     Include 'sbo' as Repository
        masm ()
        {
        if [[ ! $2 ]]; then 
        echo -e "Argument usage:\t\t<Repository>\t\t<Mirror URL>";
        return 0;
        fi
        # Check the Protocol
        [[ $2 =~ ^(http|ftp):// ]] || { echo URL Error: Neither http nor ftp.; return 1; }
        # Check the Repository
        eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
        [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
        DISTROS+=" sbo";                                # 2017-06-19 23:44:55
        [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
        # Match the URL
        m=$(grep -c "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt);     # of Matches
        ! ((m)) && { echo \Error! No matching Mirror found.; return 3; }
        url=$2;
        # Exact Matches? Also check if Single Match is an Exact Match   2017-06-16 01:00:01
        # Provide for Missing Trailing Slash        2017-06-17 15:50:45
        n=$(grep -c "\s*#\?\s*$2\s*$" /etc/usm/mirrors-$1.txt); # More Exactly Stipulated   2017-06-16 16:57:49
        # Two Part test caters for exact match not having trailing /.   #  2017-06-18 14:57:55
        ! ((n)) &&  n=$(grep -c "\s*#\?\s*${2%\/}\/\s*$" /etc/usm/mirrors-$1.txt); # More Exactly # No Exact Match
        if ! ((n)); then    w=$(grep "\s*#\?\s*$2" /etc/usm/mirrors-$1.txt | sed s/^\s*#*\s*//)
            echo Partial Match found. Select a Mirror or Enter 0 to quit.; select p in $w; do break; done
            [[ $p ]] || return 4;
            url=$p;     # URL confirmed to exactly match.
        fi
        # If more than one Exact Match, first one will be used.
        # Block All Mirrors
        sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
        # Unblock Selected  Just Once
        sudo sed -i "0,\%^\s*#\s*$url%s??$url?" /etc/usm/mirrors-$1.txt
        echo Done!; echo $1 mirror set to: $(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);             # Providing more accurate information  2017-06-17 15:46:39
        }
        kpv ()
        {
        ## Verification by Key Press        2015-02-12 00:11:36 
        local nu; local k;
            while (( 1 ))
            do
              read -s -n1 -p "$1? [Y/n]" k
              case $k in
              "$nu"    )    echo ""; return 0;;
              [yY]    )    echo ""; return 0;;
              [nN]    )    echo ""; return 1;;
            *    )  echo $'\n'"Invalid Key '$k'"
              esac
            done
        }
        proto="(http|ftp)://[^[:space:]]+";
        hash="[[:space:]]*#?[[:space:]]*"
        safm ()
        {
        if [[ ! $1 ]]; then 
        echo -e "Argument usage:\t\t<Repository>\t\t[<# of Mirrors to Display (default=6)>]";
        return 0;
        fi
        # Check the Repository
        eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
        [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
        DISTROS+=" sbo";                                # 2017-06-19 23:44:55
        [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
        # Get Relevant Files
        inits="sesm main source fasm"
        readarray -t way < <(for d in $inits; do [[ -f /tmp/$d/$1.lst ]] && cat /tmp/$d/$1.lst ; done | sort -k3  | cut -d\  -f2-)            # Work Array
        unset fay; declare -A fay; unset uny                      # Filter Array; Unique Array
        # Add Current Mirror to Filter                      2017-07-03 15:00:32
        [[ $(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt) =~ $proto ]] || return 3;
        fay[${BASH_REMATCH%/}]=;    # Subscript for Current Mirror  2017-07-03 15:00:32
        # Display Current Mirror                            2017-07-04 13:07:16
        echo ; echo Current Mirror: $BASH_REMATCH; echo Alternative Mirrors;
        # Filter with Trailing Slash Removed                2017-07-03 15:00:32
        for w in "${way[@]}"; do u=${w% *}; [[ -v fay[${u%/}] ]] && continue; fay[${u%/}]=; uny+=("$w"); done
        # 'Select' Array    <-  Unique Array Slice
        say=("${uny[@]:0:${2:-6}}")
        while ((${#say[*]})); 
        do
            select  v in "${say[@]}"; 
            do 
                [[ $v ]] || continue; unset say[$REPLY-1]; say=("${say[@]}");   # Shrink Array  
                masm $1 ${v% *} || return $?; break; 
            done
            kpv "Another Alternative" || break;
        done
        ((${#say[*]})) || echo -n "Choices Exhausted! ";
        echo Terminating.
        }
        safm $*
         
      • Usage

        Code: Select all

        guest@porteus:~$ bash $g/safm.sh
        Argument usage:         <Repository>            [<# of Mirrors to Display (default=6)>]
         
      • Illustration:
        • Fastest Slackware Mirror set for Repo

          Code: Select all

          guest@porteus:~$ bash  fasm.sh   salix
          
          All Exclusion URLs:
          Cmd Line URLs=0         File (.usm/badmirrors.txt) URLs=64      Merged(Unique) URLs=64
          Testing ftp://ftp.belnet.be/mirror/salixos.org 4.001263
          Mirrors=28              Processed=2             Remaining=26
          ...
          Testing ftp://mirrors.xmission.com/salix 4.001285
          Mirrors=28              Processed=25            Remaining=3
          Done!
          salix mirror set to: http://ftp.nux.ipb.pt/dists/salix
          
        • Paves way for safm Run

          Code: Select all

          guest@porteus:~$ sh  crm.sh  salix
          SALIX
          Mirror: http://ftp.nux.ipb.pt/dists/salix
          27 Commented Out
          
          guest@porteus:~$ bash safm.sh salix 
          1) http://ftp.nluug.nl/os/Linux/distr/salix 0.088181
          2) http://ftp.belnet.be/salixos.org 0.092429
          3) http://www.mirrorservice.org/sites/download.salixos.org 0.108272
          4) http://ftp.heanet.ie/pub/salix 0.127224
          5) http://slackware.org.uk/salix 0.135067
          6) http://mirrors.nix.org.ua/linux/salixos 0.137929
          #? 3
          Done!
          salix mirror set to: http://www.mirrorservice.org/sites/download.salixos.org
          Another Alternative? [Y/n]
          Invalid Key '5'
          Another Alternative? [Y/n]
          1) http://ftp.nluug.nl/os/Linux/distr/salix 0.088181
          2) http://ftp.belnet.be/salixos.org 0.092429
          3) http://ftp.heanet.ie/pub/salix 0.127224
          4) http://slackware.org.uk/salix 0.135067
          5) http://mirrors.nix.org.ua/linux/salixos 0.137929
          #? 4
          Done!
          salix mirror set to: http://slackware.org.uk/salix
          Another Alternative? [Y/n]
          Terminating.
          
          guest@porteus:~$ sh  crm.sh  salix
          SALIX
          Mirror: http://slackware.org.uk/salix
          27 Commented Out
      • Script safm.sh makes use of masm, the script to Manually Set a Mirror for a Repository. Consequently masm.sh can be cut out from safm.sh:

        Code: Select all

        sed "s/\s*kpv\s*().*/masm \$*/;T;q"  safm.sh > masm.sh
        :beer:
      Icing on Cake

      Script to Set Slackware Mirrors for USM (aka sesm.sh), final enhancement to allow Command Line List of Mirror Exclusion URLs plus Optional Exclusion File of URLs: .usm/badmirrors.txt (following format of 'mirrors-<repo>,txt').
      • Usage

        Code: Select all

        guest@porteus:~$ bash  sesm.sh
        Argument usage:         all     [<Toggle Debug: 0/1>]   [ URL .. ]
        URL .. Optional Exclusion Mirror List on Command Line
        Optional Exclusion File of URLs: .usm/badmirrors.txt (following format of 'mirrors-<repo>,txt')
        
      • Script sesm.sh

        Code: Select all

        #!/bin/bash
        # sesm.sh   Set the Slackware Miirors for usm Repos    Bogomips    2017-06-13 19:33:50
        # fasm.sh   Adaptation by Bogomips to Set Fastest Slackware Repository Mirror   2017-06-07 21:35:10
        
        # Last Update   2017-06-30 21:49:19 Comments; bad(): Output msgs + formatting
        # 2017-06-29 23:22:09   Sourcing:  FUNCNAME[1]==source    (,|source) <file>     2017-06-29 23:19:54
        # 2017-06-29 16:11:24   Streamlinig with Constants: $hash & $proto
        # 2017-06-29 16:11:24   Impleemented Single Mirror Repo Exception from Exclusion
        # 2017-06-27 22:50:12   Bad Mirrors list in file '.usm/badmirrors.txt' merge with Command Line URL Esclusion List
        # Internal reference  $g/usm/sesm_300617.sh
        # 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>
        # This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt
        # Constants
        proto="(http|ftp)://[^[:space:]]+";
        hash="[[:space:]]*#?[[:space:]]*"
        sus="Argument usage:\t\tall\t[<Toggle Debug: 0/1>]\t[ URL .. ]\nURL .. Optional Exclusion Mirror List on Command Line\nOptional Exclusion File of URLs: .usm/badmirrors.txt (following format of 'mirrors-<repo>,txt')"
        fs0="Argument usage:\t\t<Repository>\t\t"; fus=$fs0[${sus#*[};  #   2017-06-30 22:53:54
        fsm="Warning! No Mirror Timings obtained for Repo: \${1^^}\$'\n'No Mirror Alteration made.";
        # Assoc Arrays to be Global
        unset allm; declare -A allm;    # Used to Validate URL
        unset bay; declare -A bay;      # Used to Skip testing of URL
        ## Verification by Key Press		2015-02-12 00:11:36 
        kpv ()
        {
        local nu; local k;
            while (( 1 ))
            do
              read -s -n1 -p "$1? [Y/n]" k
              case $k in
              "$nu"	)	echo ""; return 0;;
              [yY]	)	echo ""; return 0;;
              [nN]	)	echo ""; return 1;;
        	*	)  echo $'\n'"Invalid Key '$k'"
              esac
            done
        }
        # Function bad()
        # Ascertains if a debug option was defaulted, and sets debug toggle accordingly.
        
        # Exclusion from Testing
        #   Cmd Line URLs
        # Checks Protocols of Cmd Line URLs
        # Checks Relevance of Cmd Line URLs (corresponds to entry in 'mirrors-<repo>.txt')
        # Lists them out.
        
        # Exclusion from Testing
        # File ('.usm/badmirrors.txt' similar format to 'mirrors-<repo>.txt' files)  URLs
        # Option to Proceed if no URLs found in file.
        # Checks Relevance of Cmd Line URLs (correspond to entry in 'mirrors-<repo>.txt'?)
        # List irrelevant URLs found in file together with containing line in file.
        # Option to Proceed if irrelevant URLs found in file.(not in 'mirrors-<repo>.txt')
        bad ()
        {
        err="Error! "
        bm=("Mirror Parameter neither http nor ftp:" "Command Line URL not found in Mirrors' List:");
        # Command Line      2017-06-25 15:01:32
        #   Debug Option?
        dfl=""; [[ $2 =~ ^[0-9]+$ ]] && { dfl=$2; shift; }
        shift;
        
        # Split Cmd Line URLs into pass 'pay' and fail 'fay' categories.
        unset pay fay ret; [[ $* ]] && echo;                    # No Cmd Line URLs
        for l in $*; do if [[ $l =~ ^(http|ftp) ]]; then    pay+=($l);    else    fay+=($l); fi done
        
        # Announce Erronous Mirrors
        if [[ -v fay ]]; then ret=6; echo $err${bm[ret-6]}; 
            for l in ${fay[*]}; do echo $l; done
        fi
        
        # Check Cmd Line URL for Relevance
        
        #       Array allm[*] populated with URLs from 'mirrors-<repo>.txt' Time (0.114")
        for r in $DISTROS; do 
            readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$r.txt);
            for l in "${f[@]}"; do [[ $l =~ ^$hash($proto) ]] && allm[${BASH_REMATCH[1]%/}]=; done
        #    for l in "${f[@]}"; do [[ $l =~ ^$hash((http|ftp).*) ]] && allm[${BASH_REMATCH[1]%/}]=; done
        done    
        
        # Assoc Array 'allm' of All Mirrors now Set
        
        for u in ${pay[*]}; do if [[ ! -v allm[${u%/}] ]]; then [[ ret++ -lt 7 ]] && { ret=7; echo $err${bm[ret-6]}; }
            echo $u; fi
        done
        ((ret)) && return $ret;             # Irrelevant URL Error Return.
        
        # Announce Cmd Line URLs
        if ((${#pay[*]})); then    echo Exclusion URL Specified on Command Line:;
            for u in ${pay[*]}; do bay[${u%/}]= ; echo $u; done
        fi
        # Keep Count of Cmd Line URLs
        ucmd=${#pay[*]}; unset ufle umge
        
        # Check for file: '.usm/badmirrors.txt'
        [[ -f  .usm/badmirrors.txt ]] || { echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=0\tMerged(Unique) URLs=${#bay[*]}"; return 0; }
        
        mc=$(grep -Ec "^$hash$proto" .usm/badmirrors.txt);    # Mirror Count
        if ! ((mc)); then echo "No URL found in File '.usm/badmirrors.txt'";
            kpv Proceed || return 10; return 0;
        fi
        # Keep Count of File URLs
        ufle=$mc;
        
        # Validate the URLs in File
        #   Read URLs into Work Array
        readarray -t way < <(grep -E "^$hash$proto" .usm/badmirrors.txt)
        # readarray -t way < <(grep -E "^\s*#*\s*$proto" .usm/badmirrors.txt)
        [[ mc -ne ${#way[*]} ]] && { echo -e "Internal Error! grep/bash count differ: mc=$mc\t\${#way[*]}=${#way[*]}"; return 11; };
        
        # Relevance Check for File URLs
        unset fay;          # Fail Array
        for w in "${way[@]}";
        do 
            [[ $w =~ ^$hash($proto) ]] || { echo "Internal Error! grep/bash RE clash: w='$w'"; return 12; }
            u=${BASH_REMATCH[1]%/};         # Isolated URL
            if [[ ! -v allm[$u] ]]; then    [[ -v fay ]] || { ret=12; echo $err${bm[1]/     Command Line/File}; }
                fay+=($u); [[ $u == $w ]] && echo $u || echo $u$'\n'$w; echo;
            else
                bay[$u]=;
            fi
        done
        ((ret)) && { kpv Proceed || return $ret; }
        
        # Keep Count of Unique URLs
        umge=${#bay[*]}
        ((ucmd+ufle)) && echo -e "\nAll Exclusion URLs:\nCmd Line URLs=$ucmd\t\tFile (.usm/badmirrors.txt) URLs=$ufle\tMerged(Unique) URLs=$umge"
        # "Cmd Line URLs=$ucmd\tFile URLs=$ufle\t\tMerged(Unique) URLs=$umge"
        return 0;
        }
        # Get Fastest Mirror
        fam() {
        # 1st Parameter if set, toggles Selection to only Process Bad Mirrors.   2017-06-28 23:01:06
        # 2nd Parameter aaumed never to be set
        
        ## get list
        local -n MIRRORS=${2:-may};         # Changed from 1s to 2nd Para.  2017-06-29 15:58:55
        
        ## Number of seconds before the test is considered a failure
        TIMEOUT="4"
        
        ## String to store results in
        RESULTS=""
        # Elapsed Time Check        Output an Update every 5 sec.
        let x=SECONDS;
        
        for ((i=0; i<${#MIRRORS[*]}; i++)) ; do     MIRROR=${MIRRORS[i]};
            let y=SECONDS;
            if [[ y-x -gt 5 && i -gt 0 ]]; then
                tail -n1 $RAW;
                echo -e "Mirrors=${#MIRRORS[*]}\t\tProcessed=$i\t\tRemaining=$((${#MIRRORS[*]}-i))";
                let x=SECONDS;      # Reset
            fi
            # Implementing Exclusive OR, Ensuress Processing if TRUE.    2017-06-28 19:51:57
            [[ ! $1 && ${bay[${MIRROR%/}]+x} ]] && continue;    # Exclude   2017-06-25 22:26:41
            [[ $1 && ! ${bay[${MIRROR%/}]+x} ]] && continue;    # Exclude   2017-06-28 19:51:57     2nd Part of XOR
            echo -n "Testing ${MIRROR} " >> $RAW
         
            URL="${MIRROR}%{FILE}"
        	
        	TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL`
        	
        	if [[ $TIME =~ ^0.000 ]] ; then
        		echo "Fail" >> $RAW;
        	else 
        		echo $TIME >> $RAW
        		RESULTS="${RESULTS}${TIME}\t${MIRROR}\n";
        	fi
        done;
        
        echo -e $RESULTS | sort -n > $DUMP
        FMIR=""; FMIR=`sed '/^$/d' $DUMP | head -n1 | awk '{print$2}'`;     # Reset 2017-06-28 16:54:03
        }
        
        # Get Fastest Slackware Mirror for Repository
        fasm ()
        {
        if [[ ! $1 ]]; then 
        echo -e $fus;     # fasm()  Independent   2017-06-27 22:36:55                  
        return 0;
        fi
        
        # Check the Repository      2017-06-15 00:45:36
        if [[ ! ${FUNCNAME[1]} || ${FUNCNAME[1]} =~ ^(main|source)$ ]]; then   # Sourcing (,|source) <file>     2017-06-29 23:19:54     Functioning Independently
            eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
            [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
            DISTROS+=" sbo";                                # 2017-06-19 23:44:55
            [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
            bad $* || return $?         # fasm()  Independent   2017-06-26 13:36:55
        fi
        
        dbg=${dfl:-0};                    # fasm()  Independent   2017-06-26 13:36:55
        # Introduce Directory Area TED in /tmp                  2017-06-15 17:27:27
        if [[ ! $RAW ]]; then   TED=${FUNCNAME[1]};
            [[ -d /tmp/${TED:=fasm} && -w /tmp/$TED ]] || mkdir /tmp/$TED || mkdir /tmp/$TED${SECONDS:0:-2}    # Tags the nearest 100 secs of Up Time
        fi
        RAW=/tmp/$TED/$1.lst; echo -n > $RAW;                     # Initialise.   2017-06-15 17:42:11
        ((dbg)) && echo -e "Raw Output:\t$RAW\nSorted Output:\t$DUMP";
        
        # Truncate Mirror List at Slackware Current
        readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);
        ((${#f[*]})) || { echo Empty Mirror File\!; return 3; }
        
        # Isolate Links
        # Array f now contains Relevant Section of Mirror File
        # Process f to set up Array of Mirrors 'may': http or ftp Protocol Links.
        unset may; for l in "${f[@]}"; do [[ $l =~ ^$hash($proto) ]] && may+=(${BASH_REMATCH[1]}); done    # Array Correction  2017-06-13 14:26:06     & FTP     2017-06-09 00:32:14
        
        ((dbg)) && echo Links=${#may[*]};   # of Mirror Links
        
        ## Vars
        DUMP=/tmp/.fmr.tmp
        
        # Avoid Duplicated Effort in case of Slackwar/Slackwarepatches
        if [[ $SMIR  &&  $1 =~ slackware ]]; then   FNIR=$SMIR;
            ((dbg)) && echo FMIR=$FMIR;
        else    fam;
            # Check there is a Fastest Mirror Found.
            [[ $FMIR ]] || fam  rev;    # Rerun using Eliminated if Any
            [[ $FMIR ]] || { eval echo -e $fsm; return 8; }     # All Mirrors u/s
            # Show time aassociated with Fastest Mirror (debug option)
            ((dbg)) && echo FMIR=$(grep $FMIR $RAW | cut -d " " -f2-);     # Updated to allow for own directory in /tmp unsing global RAW  2017-06-16 18:11:42
            [[ $1 =~ slackware ]] && SMIR=$FMIR
        fi    
        
        # Set the Mirror
        
            # COMMENT OUT ALL Others
        sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
        
            # UNCOOMMENT FASTEST    JUST ONCE!
        sudo sed -i "0,\%^\s*#\s*$FMIR%s??$FMIR?" /etc/usm/mirrors-$1.txt
        
        # Internal Error? Check that there is one Unblocked Mirror
        e=$(grep -E "^\s*$proto" /etc/usm/mirrors-$1.txt);    # 2017-06-11 23:49:14
        m=$(grep -Ec "^\s*$proto" /etc/usm/mirrors-$1.txt);   # 2017-06-11 23:49:14
        
        if [[ m -ne 1 ]]; then echo Internal Error\!; echo "$e"; return 4; fi
        echo Done!; echo $1 mirror set to: "$e";                  # 2017-06-11 23:52:39
        }
        sesm ()
        # Set the Slackware Miirors for All usm Repos
        {
        if [[ ! $1  ||  $1 != all ]]; then 
        echo -e $sus;
        return 0;
        fi
        # Reset Global [Switch] Varables                    2017-06-15 17:14:10
        SMIR="";    # Slackware duplication avoidance switch
        RAW="";     # Raw Output File
        # Get Distros
        eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
        [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 5; }
        DISTROS+=" sbo";                                # 2017-06-19 23:44:55
        bad $* || return $?;
        for r in $DISTROS; do echo; echo ${r^^}; fasm $r $dfl || return $?; done    # dfl 2017-06-25 15:02:34
        }
        sesm $*
        
      Run Prior to Setting Up Exclusion File of URLs

      Code: Select all

      guest@porteus:~$ time bash sesm.sh all http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/ http://mirror.internode.on.net/pub/slackware/
      
      Exclusion URL Specified on Command Line:
      http://slack.isper.sk/pub
      http://mirror.ovh.net/mirrors/ftp.slackware.com/
      http://slackware.mirrorcatalogs.com/
      http://mirror.internode.on.net/pub/slackware/
      
      All Exclusion URLs:
      Cmd Line URLs=4         File (.usm/badmirrors.txt) URLs=0       Merged(Unique) URLs=4
      
      SLACKWARE
      Testing ftp://ftp.cc.swin.edu.au/slackware/ 3.641284
      Mirrors=152             Processed=3             Remaining=149
      ...
      Testing ftp://spout.ussg.indiana.edu/linux/slackware/ 1.745081
      Mirrors=152             Processed=149           Remaining=3
      Done!
      slackware mirror set to: http://mirror.nl.leaseweb.net/slackware/
      
      SLACKWAREPATCHES
      Done!
      slackwarepatches mirror set to: http://mirror.nl.leaseweb.net/slackware/
      
      SLACKY
      Done!
      slacky mirror set to: http://repository.slacky.eu/
      
      SALIX
      Testing http://download.salixos.org Fail
      Mirrors=28              Processed=11            Remaining=17
      Testing ftp://salix.mirror.garr.it/mirrors/salix 1.105541
      Mirrors=28              Processed=17            Remaining=11
      Testing ftp://ftp.gtlib.gatech.edu/pub/salixos 4.001769
      Mirrors=28              Processed=24            Remaining=4
      Done!
      salix mirror set to: http://ftp.nux.ipb.pt/dists/salix
      
      ALIEN
      Done!
      alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
      
      PONCE
      Done!
      ponce mirror set to: http://ponce.cc/slackware
      
      SLACKONLY
      Done!
      slackonly mirror set to: http://packages.slackonly.com/pub/packages
      
      SBO
      Done!
      sbo mirror set to: http://slackbuilds.org/slackbuilds
      
      real    3m49.318s
      user    0m3.201s
      sys     0m1.860s
      
      Exclusion File of URLs. As it stands sesm.sh expects to find the URL list in file: .usm/badmirrors.txt. Hence
        • Code: Select all

          guest@porteus:~$ [[ -d ,usm ]] || mkdir .usm
        • Geographical Exclusion ( manually):
            • Using a text editor copy and paste from files /etc/usm/mirrors-<repo>.txt into file: .usm/badmirrors.txt
              • Example Contents of badmirrors.txt

                Code: Select all

                ]#----------------------------------------------------------------
                # Slackware64-14.1
                #----------------------------------------------------------------
                # AUSTRALIA (AU)
                # ftp://ftp.cc.swin.edu.au/slackware/
                # http://ftp.cc.swin.edu.au/slackware/
                # ftp://ftp.iinet.net.au/pub/slackware/
                # http://ftp.iinet.net.au/pub/slackware/
                # ftp://mirror.aarnet.edu.au/pub/slackware/
                # http://mirror.aarnet.edu.au/pub/slackware/
                # ftp://mirror.as24220.net/pub/slackware/
                # http://mirror.as24220.net/pub/slackware/
                # ftp://mirror.internode.on.net/.pub2/slackware/
                # http://mirror.internode.on.net/pub/slackware/
                # http://mirror.primusdatacentre.com.au/slackware/
                # BRAZIL (BR)
                # ftp://ftp.slackware-brasil.com.br/
                # http://ftp.slackware-brasil.com.br/
                # CHINA (CN)
                # http://mirror.bjtu.edu.cn/slackware/
                # http://mirrors.163.com/slackware/
                # http://mirrors.ustc.edu.cn/slackware/
                # INDONESIA (ID)
                # http://kambing.ui.ac.id/slackware/
                # http://repo.ukdw.ac.id/slackware/
                # JAPAN (JP)
                # ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/
                # http://ftp.nara.wide.ad.jp/pub/Linux/slackware/
                # ftp://ftp-srv2.kddilabs.jp/032/Linux/packages/Slackware/
                # http://ftp-srv2.kddilabs.jp/032/Linux/packages/Slackware/
                # ftp://riksun.riken.go.jp/Linux/slackware/
                # http://riksun.riken.go.jp/Linux/slackware/
                # SOUTH AFRICA (ZA)
                # ftp://ftp.is.co.za/mirror/ftp.slackware.com/pub/
                # http://ftp.is.co.za/mirror/ftp.slackware.com/pub/
                # ftp://ftp.wa.co.za/pub/slackware/
                # http://ftp.wa.co.za/pub/slackware/
                # ftp://slackware.mirror.ac.za/
                # http://slackware.mirror.ac.za/
                # TAIWAN (TW)
                # ftp://ftp.isu.edu.tw/pub/Linux/Slackware/
                # http://ftp.isu.edu.tw/pub/Linux/Slackware/
                # ftp://ftp.twaren.net/pub/Linux/Slackware/
                # http://ftp.twaren.net/Linux/Slackware/
            • Timings Exclusion (bit more fickle):
              • Script badm.sh retrieves the n Worst Mirrors of Named Repo from Raw Output of a sesm run.

                Code: Select all

                #!/bin/bash
                # badm.sh   Display n worst mirrors in repo by Bogomips    2017-06-23 14:54:17
                # Requires raw output of script to set fastest usm mirrors (aka sesm.sh)
                # Repo defaults to 'slackware'
                # Arbitrary cutoff points: n<100    &   (# of mirrors - n) > 9
                # Last Update: 2017-06-27 22:11:32      Fixed length Header of 88 chars.
                badm ()
                {
                um="Argument usage:\t< # of Worst Mirrors to Display >\t[Repository(default:slackware)]\nOnly run after script to set fatest usm mirrors (aka sesm.sh) has run."
                err="Error! "
                local r q=0;
                let y=1 n=-1
                [[ $1 ]] || { echo -e $um; return 0; }
                [[ $1 =~ ^[0-9]+$ ]] && let n=$1;
                [[ n -gt 100 ]] && let r=y; let y++;
                ((n)) || let r=y; let y++;
                [[ n -lt 0 ]] && let r=y; let y++;    # Non-numeric 1st Argument
                # Default slackware?
                # 2nd Argument: Repo (default: slackware)
                rpo=${2:-slackware};
                #    let z=y;     # Set 2nd Arg error message level
                # Check the Repository
                eval $(grep DISTROS= /etc/usm/usm.conf);        # Get distros list from usm.conf
                [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 9; }
                DISTROS+=" sbo";                                # 2017-06-19 23:44:55
                [[ $DISTROS =~ ([[:space:]]|^)$rpo([[:space:]]|$) ]] || let q=y; let y++;
                # Check non-numeric 2nd Arg
                [[ ! $rpo =~ ^[a-z]+$ && n -lt 0 ]] && q=0;
                # Check n ag mirror count
                #   Get mirror count
                if ! ((${r:=q})); then
                    mc=$(sed /Slackware64-current/q  /etc/usm/mirrors-$rpo.txt | grep -Ec  "^\s*#?\s*(http|ftp)");
                    # Check if remaining mirros exceed 9
                    let rm=mc-n; [[ rm -lt 10 ]]  &&  let r=y; let y++;
                    [[ -f /tmp/sesm/$rpo.lst ]] ||  let r=y; let y++;
                    if ! ((r)); then    w=""; for j in {0..79}; do w+=-; done   # Dash Line
                    h="#${w:0:8} $n Worst Mirrors ${w:0:0}${rpo^^}${w:0:8}$(date)";    # Get Measure
                    echo -e "#\n#${w:0:8} $n Worst Mirrors ${w:0:88-${#h}}${rpo^^}${w:0:8}$(date)\n#";
                    cut -d" " -f2- /tmp/sesm/$rpo.lst | sort -k2 | cut -d" " -f1 | tail -n$n
                    return 0;
                    fi
                fi
                # Error Message Output
                ms=("# requested $n > 100" "Requested 0 worst mirrors" "Non-numeric 1st argument:  '$1'" "Repo not found: '$rpo'" "Less than 10 remaining mirrors: $mc-$n=$rm" "/tmp/sesm/$rpo.lst not found. Ensure ${rpo^^} has been set thru fastest usm mirrors script (aka sesm.sh).");
                ((r)) && echo $err${ms[r-1]}
                [[ q -gt r ]] && echo $err${ms[q-1]}
                return ${q:-$r};
                }
                badm $*
                
              • Example of Appending URLs of 30 Worst Mirrors to badmirrors.txt file:

                Code: Select all

                sh   badm.sh 30  slackware >> .usm/badmirrors.txt
              • Resultant badmirrors.txt file:

                Code: Select all

                #----------------------------------------------------------------
                # Slackware64-14.1
                #----------------------------------------------------------------
                # AUSTRALIA (AU)
                # ftp://ftp.cc.swin.edu.au/slackware/
                # http://ftp.cc.swin.edu.au/slackware/
                # ftp://ftp.iinet.net.au/pub/slackware/
                # http://ftp.iinet.net.au/pub/slackware/
                # ftp://mirror.aarnet.edu.au/pub/slackware/
                # http://mirror.aarnet.edu.au/pub/slackware/
                # ftp://mirror.as24220.net/pub/slackware/
                # http://mirror.as24220.net/pub/slackware/
                # ftp://mirror.internode.on.net/.pub2/slackware/
                # http://mirror.internode.on.net/pub/slackware/
                # http://mirror.primusdatacentre.com.au/slackware/
                # BRAZIL (BR)
                # ftp://ftp.slackware-brasil.com.br/
                # http://ftp.slackware-brasil.com.br/
                # CHINA (CN)
                # http://mirror.bjtu.edu.cn/slackware/
                # http://mirrors.163.com/slackware/
                # http://mirrors.ustc.edu.cn/slackware/
                # INDONESIA (ID)
                # http://kambing.ui.ac.id/slackware/
                # http://repo.ukdw.ac.id/slackware/
                # JAPAN (JP)
                # ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/
                # http://ftp.nara.wide.ad.jp/pub/Linux/slackware/
                # ftp://ftp-srv2.kddilabs.jp/032/Linux/packages/Slackware/
                # http://ftp-srv2.kddilabs.jp/032/Linux/packages/Slackware/
                # ftp://riksun.riken.go.jp/Linux/slackware/
                # http://riksun.riken.go.jp/Linux/slackware/
                # SOUTH AFRICA (ZA)
                # ftp://ftp.is.co.za/mirror/ftp.slackware.com/pub/
                # http://ftp.is.co.za/mirror/ftp.slackware.com/pub/
                # ftp://ftp.wa.co.za/pub/slackware/
                # http://ftp.wa.co.za/pub/slackware/
                # ftp://slackware.mirror.ac.za/
                # http://slackware.mirror.ac.za/
                # TAIWAN (TW)
                # ftp://ftp.isu.edu.tw/pub/Linux/Slackware/
                # http://ftp.isu.edu.tw/pub/Linux/Slackware/
                # ftp://ftp.twaren.net/pub/Linux/Slackware/
                # http://ftp.twaren.net/Linux/Slackware/
                #
                #-------- 30 Worst Mirrors ----------------SLACKWARE--------Fri Jun 30 23:08:19 BST 2017
                #
                ftp://ftp.osuosl.org/.2/slackware/
                ftp://ftp.slackware-brasil.com.br/
                ftp://mirrors.ucr.ac.cr/slackware/pub/slackware/
                ftp://ftp-srv2.kddilabs.jp/032/Linux/packages/Slackware/
                ftp://ftp.is.co.za/mirror/ftp.slackware.com/pub/
                ftp://riksun.riken.go.jp/Linux/slackware/
                ftp://ftp.cc.swin.edu.au/slackware/
                ftp://slackware.virginmedia.com/mirrors/ftp.slackware.com/
                http://slackware.virginmedia.com/
                ftp://ftp.twaren.net/pub/Linux/Slackware/
                ftp://ftp.isu.edu.tw/pub/Linux/Slackware/
                ftp://ftp.nara.wide.ad.jp/pub/Linux/slackware/
                ftp://mirror.as24220.net/pub/slackware/
                ftp://mirror.internode.on.net/.pub2/slackware/
                http://darkstar.ist.utl.pt/pub/slackware/
                ftp://ftp.iinet.net.au/pub/slackware/
                http://carroll.aset.psu.edu/pub/linux/distributions/slackware/
                ftp://ftp.gtlib.gatech.edu/nv/ao2/lxmirror/ftp.slackware.com/
                http://mirror2.etf.bg.ac.rs/slackware/
                ftp://ftp.man.szczecin.pl/pub/Linux/slackware/
                ftp://ftp.slackware.at/
                ftp://mirror.aarnet.edu.au/pub/slackware/
                ftp://mirror2.etf.bg.ac.rs/slackware/
                http://ftp.slackware.at/data/
                ftp://gd.tuwien.ac.at/opsys/linux/freesoftware.com/
                ftp://carroll.aset.psu.edu/pub/linux/distributions/slackware/
                http://mirror.primusdatacentre.com.au/slackware/
                ftp://ftp.df.lth.se/pub/slackware/
                http://ftp.df.lth.se/pub/slackware/
                http://ftp.slackware.cz/slackware/
            Subsequent Run
              • Done with Overlap only to Illustrate Impunity with Repetition:

                Code: Select all

                guest@porteus:~$ time bash  sesm.sh all http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/ http://mirror.internode.on.net/pub/slackware/  
                
                Exclusion URL Specified on Command Line:
                http://slack.isper.sk/pub
                http://mirror.ovh.net/mirrors/ftp.slackware.com/
                http://slackware.mirrorcatalogs.com/
                http://mirror.internode.on.net/pub/slackware/
                
                All Exclusion URLs:
                Cmd Line URLs=4         File (.usm/badmirrors.txt) URLs=64      Merged(Unique) URLs=54
                
                SLACKWARE
                Testing ftp://mirror.csclub.uwaterloo.ca/slackware/ 1.790474
                Mirrors=152             Processed=24            Remaining=128
                Testing ftp://elektroni.phys.tut.fi/ 0.767548
                Mirrors=152             Processed=38            Remaining=114
                Testing http://sunsite.informatik.rwth-aachen.de/ftp/pub/comp/Linux/slackware/ 0.111911
                Mirrors=152             Processed=49            Remaining=103
                Testing ftp://patroklos.noc.ntua.gr/pub/linux/slackware/ 1.575347
                Mirrors=152             Processed=56            Remaining=96
                Testing ftp://perkons.linux.edu.lv/mirrors/ftp.slackware.com/ 0.862472
                Mirrors=152             Processed=72            Remaining=80
                Testing ftp://piotrkosoft.net/pub/mirrors/ftp.slackware.com/pub/slackware/ 1.054973
                Mirrors=152             Processed=86            Remaining=66
                Testing ftp://darkstar.ist.utl.pt/pub/slackware/ 4.000532
                Mirrors=152             Processed=92            Remaining=60
                Testing ftp://mirrors.mithril.org.ua/linux/slackware/ 0.820821
                Mirrors=152             Processed=117           Remaining=35
                Testing ftp://marmot.tn.utexas.edu/pub/slackware/ 2.284834
                Mirrors=152             Processed=130           Remaining=22
                Testing http://mirrors.kingrst.com/slackware/ 0.476239
                Mirrors=152             Processed=136           Remaining=16
                Testing http://slackbuilds.org/mirror/slackware/ 0.360582
                Mirrors=152             Processed=141           Remaining=11
                Testing ftp://teewurst.cc.columbia.edu/pub/linux/slackware/ 2.304511
                Mirrors=152             Processed=151           Remaining=1
                Done!
                slackware mirror set to: http://ftp.nluug.nl/os/Linux/distr/slackware/
                
                SLACKWAREPATCHES
                Done!
                slackwarepatches mirror set to: http://ftp.nluug.nl/os/Linux/distr/slackware/
                
                SLACKY
                Done!
                slacky mirror set to: http://repository.slacky.eu/
                
                SALIX
                Testing http://download.salixos.org Fail
                Mirrors=28              Processed=11            Remaining=17
                Testing http://salix.mirror.garr.it/mirrors/salix 0.171381
                Mirrors=28              Processed=18            Remaining=10
                Testing ftp://ftp.gtlib.gatech.edu/pub/salixos 4.001011
                Mirrors=28              Processed=24            Remaining=4
                Done!
                salix mirror set to: http://ftp.nux.ipb.pt/dists/salix
                
                ALIEN
                Done!
                alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
                
                PONCE
                Done!
                ponce mirror set to: http://ponce.cc/slackware
                
                SLACKONLY
                Done!
                slackonly mirror set to: http://packages.slackonly.com/pub/packages
                
                SBO
                Done!
                sbo mirror set to: http://slackbuilds.org/slackbuilds
                
                real    1m38.285s
                user    0m2.451s
                sys     0m1.715s
              • Time Reduced from 3 min 49 sec to 1 min 38 sec. :Yahoo!:
              Cut Out can be made from sesm.sh for the Script fasm.sh that sets the Fastest Slackware Mirror for a Repo:
              • Code: Select all

                sed "s/\s*sesm\s*().*/fasm \$*/;T;q" $g/sesm.sh > fasm.sh
                guest@porteus:~$ bash fasm.sh
                Argument usage:         <Repository>            [<Toggle Debug: 0/1>]   [ URL .. ]
                URL .. Optional Exclusion Mirror List on Command Line
                Optional Exclusion File of URLs: .usm/badmirrors.txt (following format of 'mirrors-<repo>,txt')
                
              • Code: Select all

                guest@porteus:~$ bash fasm.sh slacky
                
                All Exclusion URLs:
                Cmd Line URLs=0         File (.usm/badmirrors.txt) URLs=64      Merged(Unique) URLs=51
                Done!
                slacky mirror set to: http://slack.isper.sk/pub
                
              • At the moment badm.sh does not look for raw output of fasm, but instead needs sesm run raw output. Will be fixed for fasm in due course.
              Enjoy!

              Superseded

              Script to Set Slackware Mirrors for USM, now enhanced to allow Command Line List of Mirror Exclusion URLs. Ideally for mirrors with USM issues, and these mirrors are ones with tendency to be selected as the fastest mirrors.
              • Script sesm.sh

                Code: Select all

                #!/bin/bash
                # sesm.sh   Set the Slackware Miirors for usm Repos    Bogomips    2017-06-13 19:33:50
                #           Internal Ref (sesm_260612,sh)
                # fasm.sh   Adaptation by Bogomips to Set Fastest Slackware Repository Mirror   2017-06-07 21:35:10
                # Last Update:   2017-06-26 13:36:55    Bad Mirrors list on Command Line integrated with fasm() Independent
                
                # 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>
                # This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt
                sus="Argument usage:\t\tall\t[<Toggle Debug: 0/1>]\t[ URL .. ]\nURL .. Optional Exclusion Mirror List on Command Line"
                fus="Argument usage:\t\t<Repository>\t\t[<Toggle Debug: 0/1>]\t[ URL .. ]\nURL .. Optional Exclusion Mirror List on Command Line"
                # Assoc Arrays to be Global
                unset allm; declare -A allm;
                unset bay; declare -A bay;
                bad ()
                {
                err="Error! "
                bm=("Mirror Parameter neither http nor ftp:" "Command Line URL not found in Mirrors' List:");
                # Command Line      2017-06-25 15:01:32
                #   Debug?
                dfl=""; [[ $2 =~ ^[0-9]+$ ]] && { dfl=$2; shift; }
                shift;
                # Split into pass and fail
                unset pay fay ret; [[ $* ]] && echo;
                for l in $*; do if [[ $l =~ ^(http|ftp) ]]; then    pay+=($l);    else    fay+=($l); fi done
                # Announce Erronous Mirrors
                if [[ -v fay ]]; then ret=6; echo $err${bm[ret-6]}; 
                    for l in ${fay[*]}; do echo $l; done
                fi
                # Check good ones, if any, for Relevance
                for r in $DISTROS; do 
                    readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$r.txt);
                    for l in "${f[@]}"; do [[ $l =~ ^[[:space:]]*#?[[:space:]]*((http|ftp).*) ]] && allm[${BASH_REMATCH[1]%/}]=; done
                done    
                # Assoc Array 'allm' of All Mirrors now Set
                for u in ${pay[*]}; do if [[ ! -v allm[${u%/}] ]]; then [[ ret++ -lt 7 ]] && { ret=7; echo $err${bm[ret-6]}; }
                    echo $u; fi
                done
                ((ret)) && return $ret;     # Error Return!
                if ((${#pay[*]})); then    echo Exclusion URL Specified on Command Line:;
                    for u in ${pay[*]}; do bay[${u%/}]= ; echo $u; done
                fi
                return 0;
                }
                # Get Fastest Mirror
                fam() {
                ## get list
                local -n MIRRORS=${1:-may};
                
                ## Number of seconds before the test is considered a failure
                TIMEOUT="4"
                
                ## String to store results in
                RESULTS=""
                # Elapsed Time Check        Output an Update every 5 sec.
                let x=SECONDS;
                
                for ((i=0; i<${#MIRRORS[*]}; i++)) ; do     MIRROR=${MIRRORS[i]};
                    let y=SECONDS;
                    if [[ y-x -gt 5 && i -gt 0 ]]; then
                        tail -n1 $RAW;
                        echo -e "Mirrors=${#MIRRORS[*]}\t\tProcessed=$i\t\tRemaining=$((${#MIRRORS[*]}-i))";
                        let x=SECONDS;      # Reset
                    fi
                    [[ ${bay[${MIRROR%/}]+x} ]] && continue;    # Exclude   2017-06-25 22:26:41
                    echo -n "Testing ${MIRROR} " >> $RAW
                 
                    URL="${MIRROR}%{FILE}"
                    
                    TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL`
                    
                    if [[ $TIME =~ ^0.000 ]] ; then
                        echo "Fail" >> $RAW;
                    else 
                        echo $TIME >> $RAW
                        RESULTS="${RESULTS}${TIME}\t${MIRROR}\n";
                    fi
                done;
                
                echo -e $RESULTS | sort -n > $DUMP
                FMIR=`sed '/^$/d' $DUMP | head -n1 | awk '{print$2}'`
                }
                
                # Get Fastest Slackware Mirror for Repository
                fasm ()
                {
                if [[ ! $1 ]]; then 
                echo -e $fus;     # fasm()  Independent   2017-06-27 22:36:55
                return 0;
                fi
                
                # Check the Repository      2017-06-15 00:45:36
                if [[ ! ${FUNCNAME[1]} || ${FUNCNAME[1]} == main ]]; then   # Functioning Independently
                    eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
                    [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 1; }
                    DISTROS+=" sbo";                                # 2017-06-19 23:44:55
                    [[ $DISTROS =~ ([[:space:]]|^)$1([[:space:]]|$) ]] || { echo Error\! Repository not found.; return 2; }
                    bad $* || return $?         # fasm()  Independent   2017-06-26 13:36:55
                fi
                
                dbg=${dfl:-0};                    # fasm()  Independent   2017-06-26 13:36:55
                # Introduce Directory Area TED in /tmp                  2017-06-15 17:27:27
                if [[ ! $RAW ]]; then   TED=${FUNCNAME[1]};
                    [[ -d /tmp/${TED:=fasm} && -w /tmp/$TED ]] || mkdir /tmp/$TED || mkdir /tmp/$TED${SECONDS:0:-2}    # Tags the nearest 100 secs of Up Time
                fi
                RAW=/tmp/$TED/$1.lst; echo -n > $RAW;                     # Initialise.   2017-06-15 17:42:11
                ((dbg)) && echo -e "Raw Output:\t$RAW\nSorted Output:\t$DUMP";
                
                # Truncate Mirror List at Slackware Current
                readarray -t f < <(sed /Slackware64-current/q  /etc/usm/mirrors-$1.txt);
                ((${#f[*]})) || { echo Empty Mirror File\!; return 3; }
                
                # Isolate Links
                # Array f now contains Relevant Section of Mirror File
                # Process f to set up Array of Mirrors 'may': http or ftp Protocol Links.
                unset may; for l in "${f[@]}"; do [[ $l =~ ^[[:space:]]*#?[[:space:]]*((http|ftp).*) ]] && may+=(${BASH_REMATCH[1]}); done    # Array Correction  2017-06-13 14:26:06     & FTP     2017-06-09 00:32:14
                
                ((dbg)) && echo Links=${#may[*]};   # of Mirror Links
                
                ## Vars
                DUMP=/tmp/.fmr.tmp
                
                # Avoid Duplicated Effort in case of Slackwar/Slackwarepatches
                if [[ $SMIR  &&  $1 =~ slackware ]]; then   FNIR=$SMIR;
                    ((dbg)) && echo FMIR=$FMIR;
                else
                    # Show time aassociated with Fastest Mirror (debug option)
                    fam; ((dbg)) && echo FMIR=$(grep $FMIR $RAW | cut -d " " -f2-);     # Updated to allow for own directory in /tmp unsing global RAW  2017-06-16 18:11:42
                    [[ $1 =~ slackware ]] && SMIR=$FMIR
                fi    
                
                # Set the Mirror
                
                    # COMMENT OUT ALL Others
                sudo sed -i -E 's/^\s*(http|ftp)/# &/' /etc/usm/mirrors-$1.txt    # 2017-06-09 01:10:11
                
                    # UNCOOMMENT FASTEST    JUST ONCE!
                sudo sed -i "0,\%^\s*#\s*$FMIR%s??$FMIR?" /etc/usm/mirrors-$1.txt
                
                # Internal Error? Check that there is one Unblocked Mirror
                e=$(grep -E "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);    # 2017-06-11 23:49:14
                m=$(grep -Ec "^\s*(http|ftp)" /etc/usm/mirrors-$1.txt);   # 2017-06-11 23:49:14
                
                if [[ m -ne 1 ]]; then echo Internal Error\!; echo "$e"; return 4; fi
                echo Done!; echo $1 mirror set to: "$e";                  # 2017-06-11 23:52:39
                }
                sesm ()
                # Set the Slackware Miirors for All usm Repos
                {
                if [[ ! $1  ||  $1 != all ]]; then 
                echo -e "Argument usage:\t\t<Repository>\t\t[<Toggle Debug: 0/1>]";     # fasm()  Independent   2017-06-27 22:36:55                  
                return 0;
                fi
                # Reset Global [Switch] Varables                    2017-06-15 17:14:10
                SMIR="";    # Slackware duplication avoidance switch
                RAW="";     # Raw Output File
                # Get Distros
                eval $(grep DISTROS= /etc/usm/usm.conf);    # Get distros list from usm.conf
                [[ $DISTROS ]] || { echo Error\! File usm.conf corrupted; return 5; }
                DISTROS+=" sbo";                                # 2017-06-19 23:44:55
                bad $* || return $?;
                for r in $DISTROS; do echo; echo ${r^^}; fasm $r $dfl || return $?; done    # dfl 2017-06-25 15:02:34
                }
                sesm $*
                
              • Usage

                Code: Select all

                guest@porteus:~$ bash  sesm.sh
                Argument usage:         all     [<Toggle Debug: 0/1>]   [URL ..]
                URL .. Optional Exclusion Mirror List on Command Line
                
              • An Invocation (also being timed)

                Code: Select all

                guest@porteus:~$ time bash  sesm.sh all http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/
                
                Exclusion URL Specified on Command Line:
                http://slack.isper.sk/pub
                http://mirror.ovh.net/mirrors/ftp.slackware.com/
                http://slackware.mirrorcatalogs.com/
                
                SLACKWARE
                Testing ftp://ftp.cc.swin.edu.au/slackware/ 4.000020
                Mirrors=152             Processed=3             Remaining=149
                ...
                Testing ftp://spout.ussg.indiana.edu/linux/slackware/ 1.741021
                Mirrors=152             Processed=149           Remaining=3
                Done!
                slackware mirror set to: http://ftp.gwdg.de/pub/linux/slackware/
                
                SLACKWAREPATCHES
                Done!
                slackwarepatches mirror set to: http://ftp.gwdg.de/pub/linux/slackware/
                
                SLACKY
                Done!
                slacky mirror set to: http://repository.slacky.eu/
                
                SALIX
                Testing http://download.salixos.org Fail
                Mirrors=28              Processed=11            Remaining=17
                Testing ftp://salix.mirror.garr.it/mirrors/salix 0.972217
                Mirrors=28              Processed=17            Remaining=11
                Testing ftp://mirrors.xmission.com/salix 1.859619
                Mirrors=28              Processed=25            Remaining=3
                Done!
                salix mirror set to: http://ftp.nux.ipb.pt/dists/salix
                
                ALIEN
                Done!
                alien mirror set to: http://bear.alienbase.nl/mirrors/people/alien/sbrepos
                
                PONCE
                Done!
                ponce mirror set to: http://ponce.cc/slackware
                
                SLACKONLY
                Done!
                slackonly mirror set to: http://packages.slackonly.com/pub/packages
                
                SBO
                Done!
                sbo mirror set to: http://slackbuilds.org/slackbuilds
                
                real    3m56.477s
                user    0m2.942s
                sys     0m1.905s
                
              Script to Set Fastest USM Mirror for a Repository, now enhanced to allow Command Line List of Mirror Exclusion URLs. Ideally for mirrors with USM issues, and these mirrors are ones with tendency to be selected as the fastest mirrors. The script fasm.sh can be Cut Out from sesm.sh
              • And then run:

                Code: Select all

                guest@porteus:~$ sed "s/\s*sesm\s*().*/fasm \$*/;T;q"  sesm.sh > fasm.sh
                guest@porteus:~$ bash fasm.sh slacky http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/
                
                Exclusion URL Specified on Command Line:
                http://slack.isper.sk/pub
                http://mirror.ovh.net/mirrors/ftp.slackware.com/
                http://slackware.mirrorcatalogs.com/
                Done!
                slacky mirror set to: http://slackware.org.uk/slacky
                
                guest@porteus:~$ cat /tmp/main/slacky.lst
                Testing http://repository.slacky.eu/ 0.159170
                Testing http://slackware.org.uk/slacky 0.145915
                
              • Or, doing it with mirrors :D , in one fell swoop invoked (here in debug mode):

                Code: Select all

                guest@porteus:~$ bash <(sed "s/\s*sesm\s*().*/fasm \$*/;T;q"  sesm.sh)
                Argument usage:         <Repository>            [<Toggle Debug: 0/1>]   [ URL .. ]
                URL .. Optional Exclusion Mirror List on Command Line
                
                
                guest@porteus:~$ bash <(sed "s/\s*sesm\s*().*/fasm \$*/;T;q"  sesm.sh) salix 3 http://slack.isper.sk/pub http://mirror.ovh.net/mirrors/ftp.slackware.com/ http://slackware.mirrorcatalogs.com/
                
                Exclusion URL Specified on Command Line:
                http://slack.isper.sk/pub
                http://mirror.ovh.net/mirrors/ftp.slackware.com/
                http://slackware.mirrorcatalogs.com/
                Raw Output:     /tmp/main/salix.lst
                Sorted Output:
                Links=28
                Testing http://www.mirrorservice.org/sites/download.salixos.org 0.142796
                Mirrors=28              Processed=10            Remaining=18
                Testing http://ftp.heanet.ie/pub/salix 0.144403
                Mirrors=28              Processed=16            Remaining=12
                Testing ftp://mirrors.xmission.com/salix 2.120880
                Mirrors=28              Processed=25            Remaining=3
                FMIR=http://ftp.nluug.nl/os/Linux/distr/salix 0.090789
                Done!
                salix mirror set to: http://ftp.nluug.nl/os/Linux/distr/salix
              Enjoy!
              Last edited by Bogomips on 05 Jul 2017, 00:15, edited 19 times in total.
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#4 by Ed_P » 15 Jun 2017, 15:06

              :shock: :%)


              :D


              Would the bash invocation problem be resolved with adding:

              #!/bin/sh

              to the begining of the script(s)?

              I'm not sure, actually pretty sure, I understand what you're trying to do with this new script. The fasm.sh script you posted earlier, and my little fasmez.sh script, work great and create fast mirrors for USM so what more is needed?
              Ed

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#5 by Bogomips » 15 Jun 2017, 15:16

              Ed_P wrote:Would the bash invocation problem be resolved with adding:

              #!/bin/sh

              to the begining of the script(s)?
              TTBOMK the bash shebang requests the bash interpreter to take over. The sh interpreter has its limitations. Presume if script were made executable and invoked the same as fastest-mirror, this issue would not arise.
              Ed_P wrote:work great and create fast mirrors for USM so what more is needed?
              To be user friendly? :friends:

              Update Edit

              Actually pays to put in the extra effort: clean up comments and put in error messages. For sure as God made little apples one gets suddenly deeply involved somewhere else, and when one comes back to use what one has written, one has become the user! But with help of appropriate error messages and comments one has no need to plough once more through the code to find out why it's no longer working. 8)
              Last edited by Bogomips on 16 Jun 2017, 00:43, edited 1 time in total.
              Reason: Update Edit
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#6 by Bogomips » 18 Jun 2017, 01:44

              Pleased to be able to offer/share the fruits of my investigation into the USM Mirrors: http://forum.porteus.org/viewtopic.php? ... 1ad#p55998 :beer:
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#7 by Ed_P » 18 Jun 2017, 02:42

              Bogomips wrote:Actually pays to put in the extra effort: clean up comments and put in error messages. For sure as God made little apples one gets suddenly deeply involved somewhere else, and when one comes back to use what one has written, one has become the user! But with help of appropriate error messages and comments one has no need to plough once more through the code to find out why it's no longer working. 8)
              :lol: Been there done that. :ROFL: Useful for things distributed to others also. :)

              Bogomips wrote:Pleased to be able to offer/share the fruits of my investigation into the USM Mirrors: http://forum.porteus.org/viewtopic.php? ... 1ad#p55998 :beer:
              Posting back to the thread you're posting in isn't as effective as you may think. :D

              Also this link is just as effective: http://forum.porteus.org/viewtopic.php? ... 998#p55998 No sid operand needed.


              -edit-

              So we have: sesm.sh, usmbkup.sh, usmrstr.sh, sam.sh and masm.sh. I don't know where to create a /home/guest/USM folder for these plus a couple of other USM related scripts or a folder named /home/guest/Bogomips!! :D
              Ed

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#8 by Bogomips » 18 Jun 2017, 12:35

              ^ Re Edit. There's no need for all that .As I've said before, post also serves as a reference for myself. Don't have to rummage through my files. Just open the post, and it's all there nicely formatted. 8)
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#9 by Ed_P » 18 Jun 2017, 15:07

              Bogomips wrote:post also serves as a reference for myself. Don't have to rummage through my files. Just open the post, and it's all there nicely formatted. 8)
              Yup, I understand. That's why the 2nd line in each of the scripts is:

              Code: Select all

              #!/bin/bash
              # http://forum.porteus.org/viewtopic.php?f=39&t=7000&p=56042#p56042
              # masm.sh   Manually set Slackware Mirror by Bogomips
               :
               :
              etc
              :)
              Ed

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#10 by Bogomips » 18 Jun 2017, 21:28

              ^ Could not see third line, just to check it was corrected version, so that we're all on same page. :wink:

              Code: Select all

              #!/bin/bash
              # masm.sh   Manually set Slackware Mirror by Bogomips
              # Last Update:  2017-06-18 14:57:55     Cater for exact mirror match not having trailing /.
                
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#11 by Ed_P » 18 Jun 2017, 22:15

              Bogomips wrote:^ Could not see third line, just to check it was corrected version,

              Code: Select all

              #!/bin/bash
              # http://forum.porteus.org/viewtopic.php?f=39&t=7000&p=56042#p56042
              # masm.sh   Manually set Slackware Mirror by Bogomips
              # Last Update:  2017-06-17 15:46:39     Provide more accurate information.
              masm ()
              Ed

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#12 by Bogomips » 18 Jun 2017, 22:20

              ^ Thought if I did a bright colour, would be easier on the eyes! Yours is superseded!
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#13 by Ed_P » 18 Jun 2017, 22:29

              ^ Oh, I saw it and have updated my masm.sh file. The question is how many other files have you updated?
              Ed

              Bogomips
              Full of knowledge
              Full of knowledge
              Posts: 2564
              Joined: 25 Jun 2014, 15:21
              Distribution: 3.2.2 Cinnamon & KDE5
              Location: London

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#14 by Bogomips » 19 Jun 2017, 00:49

              Ed_P wrote:The question is how many other files have you updated?
              Answer should be none. Can check against the update times. However have updated the end of the preceding (1st Post) of topic.:)
              Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
              NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

              User avatar
              Ed_P
              Contributor
              Contributor
              Posts: 8315
              Joined: 06 Feb 2013, 22:12
              Distribution: Cinnamon 5.01 ISO
              Location: Western NY, USA

              Re: [INFO & SCRIPT] Slackware Mirror Settings for USM

              Post#15 by Ed_P » 19 Jun 2017, 03:20

              Bogomips wrote:
              Ed_P wrote:The question is how many other files have you updated?
              Answer should be none. Can check against the update times. However have updated the end of the preceding (1st Post) of topic.:)
              The end of the 1st Post of topic shows:

              Code: Select all

              Last edited by Bogomips on 18 Jun 2017, 22:01, edited 3 times in total.
              Reason: Summary of following Post.
              Not very helpful. :(

              Maybe use this posting viewtopic.php?f=39&t=7000&p=56083#p55999 for denoting scripts' update date & times.
              Ed

              Post Reply