Porteus 3.2x Newbie Install Guide Pt. 1-2

Get help with MATE specific problems
yldouright
Black ninja
Black ninja
Posts: 80
Joined: 04 Mar 2015, 16:27
Distribution: Porteus (slackware 12.1)
Location: NY

Porteus 3.2x Newbie Install Guide Pt. 1-2

Post#1 by yldouright » 26 Feb 2018, 20:22

This is a more fully explained installation guide that extends to configuration and troubleshooting after the install. I have limited its scope to version 3.2x since I am referring only to personal experience:

Part 1 - Getting a clean start

Step 1 - Download a Porteus .iso and its checksum from any of its mirrors. Select the .iso appropriate for your hardware. If you are unfamiliar with your hardware, enter your bios, write down what you see and use your search engine to learn what you have. An .iso is a disk image and the checksum is used to verify the downlaod wasn't corrupted.
Step 2 - Once you have the .iso, use a checksum utility to verify the file. There are many ways to do this, they don't cost anything and they all work. It's a good practice to do this to rule out any potential problems later.
Step 3 - Burn your .iso to your optical media or mount the .iso and copy it to any other removable drive. If you burn optical media, verify the burn. If you copied the file, do a disk check on the volume. We do this to rule out potential causes of later problems.
Step 4 - Boot from the media you just prepared. You may need to interrupt your boot procedure to select the right media or change the setting in your bios to have that image boot. Once again, look this up if you don't know how to do this.
Step 5 - Monitor the messages as the software loads. Many potential problems are exposed or hinted at during this process. You should see the Porteus 'blue page' which allows you to select how you boot. Some boot options can help workaround and identify problems you encounter using Porteus but for the time being, boot to RAM. It will take longer to boot into the desktop than the default setting but it will generally allow you more flexibility in troubleshooting and testing the OS.
Step 6 - The software should load to a fully working OS desktop. Test all the functions and software that matter to you before installing the OS. Make notes of any issues and see if solutions are available prior to installing the software. Prepare these in a handy location for when you need them.
Step 7 - If everything works as it should, you're either really lucky or running a version of Porteus 3.1 :) Seriously, if you tried USM you noted that the databases fail to update properly and in some cases break your system. A big thanks goes to @Bogomips for his solution to this. He constructed three scripts (sesm.sh, safm.sh and badm.sh) found here, that add and purge depositories so USM works properly.
Step 8 - Once you are confident that you can get and run what you need on your system, you can begin making a permanent installation. The procedures will differ slightly depending on where and how you will install it and those will be covered in part 2 of this tutorial.

In Part 1 we did the preliminary investigation of the Porteus OS prior to the install. You should have identified any problem hardware and discovered any software unavailable to your desired build so now we’re ready to copy the OS to the media and complete the installation.

Part 2 – Getting the OS where and how you want it.

Step 1 – You’ve booted your Live OS Install disk and are now logged on to the desktop. You should know which drive you are installing on. If you have multiple drives in your box, make sure you know which is which. Without this information you may overwrite things you don’t want to. Once you know which drive you want to install on, go to your application menu and locate the “Porteus System Installer”. One thing you need to understand is that this installer does not actually install a working system. It only copies the working OS to your disk. To get an OS that boots you will need to activate it but we’ll get to that later. You need to decide if your install will stand alone or share the disk with another OS.
Step 2 – If your install will stand alone, it is recommended to format the drive with a Unix type filesystem. I prefer the default “ext4” filesystem for Porteus but you may choose any you wish. If you choose a Windows/DOS filesystem, you will need to use the Windows script at the end of the install instead of the “Porteus-installer-for-Linux.com” script. Gparted is the application Linux typically uses to create the filesystem. When your drive is ready, it will show up in the installer list. If it doesn’t, just select ‘mount drive’ to find it and select it. Click “Next” to start the copy process.
Step 3 – You will then be presented with a dialog asking you to install the bootloader. Unless you plan to use a separate bootloader, you must select both those checkboxes for your installation to boot. After a few minutes, you will be presented a terminal to input the install script. Type Porteus-installer-for-Linux.com to run the script if you’re installing on a Unix filesystem. If it’s a Windows filesystem, type Porteus-installer-for-Windows.com.
Step 4 – If all went well, you will receive a message in the terminal asking you to type “ok” to complete the installation. Do so and reboot. If you have only one drive in your system; flash drives, media cards, optical media and the like are also drives; and it still doesn’t boot, review the instructions again because I’m pretty confident this is on you. If you booted into another OS or the OS didn’t boot, you may need to use the bios boot interrupt function key to select the right drive or go into your bios to change your boot order.
Step 5 – If you have decided to share your drive with another OS, you will have to wait for Part 3 for further instruction but if not, Porteus will present you with its soon to be familiar blue splash screen. You'll have time to set your boot choice but this and other boot parameters are configurable later in the OS. You should note how much faster the boot happened from the hard drive. Okay, now you’ve got a stripped down system and you need to get your software but wherefrom? Let’s enable your network.
Step 6 – On the upper right hand side of your display you will find the network icon. You may wish to set your passwords prior to enabling and configuring your network but it’s not a requirement to get access to USM depositories. Passwords for your root and guest accounts are done from the “Application:System Tools:Porteus Settings Centre” menu. Click the “lock” icon there to enter the change. The default passwords for root and guest accounts are “toor” and “guest” respectively. Once your network is enabled you need to update the USM depository database.
Step 7 - USM is the Slackware equivalent of Synaptic on Debian based Linux. Unfortunately, it’s not working so great since Porteus v_3.1 but there are usually alternative ways to get things done in Linux. Click on the USM icon on the middle left side of the top menu bar. You should get a notice of missing database files. Do NOT use USM to update your databases, we’ll use a terminal but before that, we need to check our database sources. Fortunately, Porteus Forum member Bogomips wrote some scripts to do this for us and they are included below:

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 $*
Copy the sesm.sh script code and save it to a plain text file and name it “sesm.sh”. Repeat this process for both the safm.sh below:

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 $*
and badm.sh script codes.

Code: Select all

badm.sh 3 salix >> .usm/badmirrors.txt
In order to use the badm.sh script properly you need to create a directory to store the output prior to running it. Create a hidden directory inside the usm directory by going there as root, opening a terminal and typing mkdir .usm. Its use is optional . Open terminal in the directory where you saved those scripts. Enter su and your root password to run these scripts. The root password is “toor” if you didn’t change it as described earlier. Type sh sesm.sh in the terminal. This script should prevent source database faults when you run the next command, usm -u all. The terminal should show the depositories updating, wait until they’re done. If there were no issues, you should be able to use USM to search for and install your desired software.
Step 8 – If you experienced broken/missing/corrupted databases, you will need to run the other two scripts above in the following order; sh safm.sh will select and promote the good depositories and if you created the hidden ".usm" directory, sh badm.sh will purge and remove the worst ones and save them in a file in the event they can be redeemed later. Run the usm -u all command once again to correct the previoius database errors. That’s it for Part 2, Part 3 gets into setting up your OS for problem free operation and provides software recommendations for common computer functions.