Merge pull request #5 from pyr0ball/develop

[New Features] v1.6.x - Adding OS agnostic functions, package management
added new function `install-package()` which accepts either a package name used with your local package manager, or a local file *.deb or *.rpm and automatically chooses the correct method for installation based on the system and available binaries
This commit is contained in:
Alan Weinstock 2023-06-15 02:16:42 -07:00 committed by GitHub
commit 4c8211b4f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

557
functions
View file

@ -2,7 +2,7 @@
# pyr0ball script functions library
# Initial Vars
functionsrev=1.3.0
functionsrev=1.6.0
#scriptname="${BASH_SOURCE[0]##*/}"
#rundir="${BASH_SOURCE[0]%/*}"
#rundir_absolute=$(cd $rundir && pwd)
@ -10,6 +10,9 @@ functionsrev=1.3.0
pretty_date="$(date +%Y-%m-%d_%H-%M-%S)"
short_date="$(date +%Y-%m-%d)"
# ensure ctrl-c to cancel script ends the entire process and not just the current function
# trap ctrl_c INT # Commented out by default to prevent abnormal background exits
# return any cursor mods to normal on exit
cleanup(){
tput cnorm
@ -98,194 +101,160 @@ else
BOXWIDTH=80
fi
set_borders() {
top_border=$1
bottom_border=$2
left_border=$3
right_border=$4
left_top_border=$5
right_top_border=$6
left_bottom_border=$7
right_bottom_border=$8
box_break_line=$9
}
# # Box Drawing characters
# case $OSTYPE in
# linux-gnu*|cygwin|msys)
# light_h='\u2500'
# norm_h='\u2501'
# double_h='\u2550'
# light_v='\u2502'
# norm_v='\u2503'
# double_v='\u2551'
# ;;&
# darwin* )
# light_h='─'
# norm_h='━'
# double_h='═'
# light_v='│'
# norm_v='┃'
# double_v='║'
# ;;
# esac
# # Box border type single-line
# box-norm() {
# case $OSTYPE in
# linux-gnu*|cygwin|msys)
# set_borders "${norm_h}" "${norm_h}" "${norm_v}" "${norm_v}" "\u250f" "\u2513" "\u2517" "\u251b" "\u25AB"
# set_borders "${double_h}" "${double_h}" "${double_v}" "${double_v}" "\u2554" "\u2557" "\u255A" "\u255D" "\u25AB"
# set_borders "\u2580" "\u2584" "\u258C" "\u2590" "\u259B" "\u259C" "\u2599" "\u259F" "\u25AB"
# set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "\u25AB" "\u25AB" "\u25AB" "\u25AB" "\u23AF"
# set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "\u256D" "\u256E" "\u2570" "\u256F" "\u25A2"
# Box Drawing characters
case $OSTYPE in
linux-gnu*|cygwin|msys)
light_h=$(echo -e "\u2500")
norm_h=$(echo -e "\u2501")
double_h=$(echo -e "\u2550")
light_v=$(echo -e "\u2502")
norm_v=$(echo -e "\u2503")
double_v=$(echo -e "\u2551")
light_h='─'
norm_h='━'
double_h='═'
light_v='│'
norm_v='┃'
double_v='║'
;;&
darwin* )
light_h=$(echo -e "─")
norm_h=$(echo -e "━")
double_h=$(echo -e "═")
light_v=$(echo -e "│")
norm_v=$(echo -e "┃")
double_v=$(echo -e "║")
light_h='─'
norm_h='━'
double_h='═'
light_v='│'
norm_v='┃'
double_v='║'
;;
esac
set_borders() {
top_border=$1
bottom_border=$2
left_border=$3
right_border=$4
left_top_border=$5
right_top_border=$6
left_bottom_border=$7
right_bottom_border=$8
box_break_line=$9
}
# Box border type single-line
box-norm(){
# ---------------------------------------#
# Box border type single-line
box-norm() {
case $OSTYPE in
linux-gnu*|cygwin|msys)
top_border=${norm_h}
bottom_border=${norm_h}
left_border=${norm_v}
right_border=${norm_v}
left_top_border=$(echo -e "\u250f")
right_top_border=$(echo -e "\u2513")
left_bottom_border=$(echo -e "\u2517")
right_bottom_border=$(echo -e "\u251b")
box_break_line=$(echo -e "\u25AB")
set_borders "${norm_h}" "${norm_h}" "${norm_v}" "${norm_v}" "┏" "┓" "┗" "┛" "▫"
;;&
darwin* )
top_border=${norm_h}
bottom_border=${norm_h}
left_border=${norm_v}
right_border=${norm_v}
left_top_border=$(echo -e "┏")
right_top_border=$(echo -e "┓")
left_bottom_border=$(echo -e "┗")
right_bottom_border=$(echo -e "┛")
box_break_line=$(echo -e "▫")
set_borders "${norm_h}" "${norm_h}" "${norm_v}" "${norm_v}" "┏" "┓" "┗" "┛" "▫"
;;
esac
# ---------------------------------------#
}
# Box border type double-line
box-double(){
# ---------------------------------------#
# Box border type double-line
box-double() {
case $OSTYPE in
linux-gnu*|cygwin|msys)
top_border=${double_h}
bottom_border=${double_h}
left_border=${double_v}
right_border=${double_v}
left_top_border=$(echo -e "\u2554")
right_top_border=$(echo -e "\u2557")
left_bottom_border=$(echo -e "\u255A")
right_bottom_border=$(echo -e "\u255D")
box_break_line=$(echo -e "\u25AB")
set_borders "${double_h}" "${double_h}" "${double_v}" "${double_v}" "╔" "╗" "╚" "╝" "▫"
;;&
darwin* )
top_border=${double_h}
bottom_border=${double_h}
left_border=${double_v}
right_border=${double_v}
left_top_border=$(echo -e "╔")
right_top_border=$(echo -e "╗")
left_bottom_border=$(echo -e "╚")
right_bottom_border=$(echo -e "╝")
box_break_line=$(echo -e "▫")
set_borders "${double_h}" "${double_h}" "${double_v}" "${double_v}" "╔" "╗" "╚" "╝" "▫"
;;
esac
# ---------------------------------------#
}
# Box border type thick-line
# Box border type thick-line
box-heavy(){
# ---------------------------------------#
case $OSTYPE in
linux-gnu*|cygwin|msys)
top_border=$(echo -e "\u2580")
bottom_border=$(echo -e "\u2584")
left_border=$(echo -e "\u258C")
right_border=$(echo -e "\u2590")
left_top_border=$(echo -e "\u259B")
right_top_border=$(echo -e "\u259C")
left_bottom_border=$(echo -e "\u2599")
right_bottom_border=$(echo -e "\u259F")
box_break_line=$(echo -e "\u25AC")
set_borders "▀" "▄" "▌" "▐" "▛" "▜" "▙" "▟" "▫"
;;&
darwin* )
top_border=$(echo -e "▀")
bottom_border=$(echo -e "▄")
left_border=$(echo -e "▌")
right_border=$(echo -e "▐")
left_top_border=$(echo -e "▛")
right_top_border=$(echo -e "▜")
left_bottom_border=$(echo -e "▙")
right_bottom_border=$(echo -e "▟")
box_break_line=$(echo -e "▫")
set_borders "▀" "▄" "▌" "▐" "▛" "▜" "▙" "▟" "▫"
;;
esac
# ---------------------------------------#
}
# Box border type thin-line
# Box border type thin-line
box-light(){
# ---------------------------------------#
#top_border=$(echo -e '\u23BA')
case $OSTYPE in
linux-gnu*|cygwin|msys)
top_border=${light_h}
bottom_border=${light_h}
left_border=${light_v}
right_border=${light_v}
left_top_border=$(echo -e "\u25AB")
right_top_border=$(echo -e "\u25AB")
left_bottom_border=$(echo -e "\u25AB")
right_bottom_border=$(echo -e "\u25AB")
box_break_line=$(echo -e "\u23AF")
set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "▫" "▫" "▫" "▫" "⎯"
;;&
darwin* )
top_border=${light_h}
bottom_border=${light_h}
left_border=${light_v}
right_border=${light_v}
left_top_border=$(echo -e "▫")
right_top_border=$(echo -e "▫")
left_bottom_border=$(echo -e "▫")
right_bottom_border=$(echo -e "▫")
box_break_line=$(echo -e "⎯")
set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "▫" "▫" "▫" "▫" "⎯"
;;
esac
# ---------------------------------------#
}
box-rounded(){
# ---------------------------------------#
box-rounded(){
case $OSTYPE in
linux-gnu*|cygwin|msys)
top_border=${light_h}
bottom_border=${light_h}
left_border=${light_v}
right_border=${light_v}
left_top_border=$(echo -e "\u256D")
right_top_border=$(echo -e "\u256E")
left_bottom_border=$(echo -e "\u2570")
right_bottom_border=$(echo -e "\u256F")
box_break_line=$(echo -e "\u25A2")
set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "╭" "╮" "╰" "╯" "▢"
;;&
darwin* )
top_border=${light_h}
bottom_border=${light_h}
left_border=${light_v}
right_border=${light_v}
left_top_border=$(echo -e "╭")
right_top_border=$(echo -e "╮")
left_bottom_border=$(echo -e "╰")
right_bottom_border=$(echo -e "╯")
box_break_line=$(echo -e "▢")
set_borders "${light_h}" "${light_h}" "${light_v}" "${light_v}" "╭" "╮" "╰" "╯" "▢"
;;
esac
# ---------------------------------------#
}
box-singlechar(){
# ---------------------------------------#
top_border=$borderchar
bottom_border=$borderchar
left_border=$borderchar
right_border=$borderchar
left_top_border=$borderchar
right_top_border=$borderchar
left_bottom_border=$borderchar
right_bottom_border=$borderchar
box_break_line="-"
# ---------------------------------------#
box-singlechar(){
set_borders "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "-"
}
set-boxtype(){
set-boxtype(){
case $boxtype in
norm) box-norm ;;
double) box-double ;;
heavy) box-heavy ;;
light) box-light ;;
rounded) box-rounded ;;
char) box-singlechar ;;
esac
}
box-singlechar(){
set_borders "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "-"
}
set-boxtype(){
case $boxtype in
norm) box-norm ;;
double) box-double ;;
@ -299,25 +268,43 @@ set-boxtype(){
#set-boxtype
repchar() {
n=1
while [ $n -le $2 ] ; do
echo -n "$1"
n=$((n+1))
if [[ $# -ne 2 || ! $2 =~ ^[0-9]+$ ]]; then
warn "repchar() Incorrect usage. Usage: repchar <char> <count>"
return 1
fi
local char="$1"
local count="$2"
for (( i=0; i<$count; i++ )); do
printf "%s" "$char"
done
}
boxtop() {
echo -n "$left_top_border"
repchar "$top_border" $((BOXWIDTH-1))
echo -n "$right_top_border"
echo
boxtop() {
printf "%s%s%s\n" "$left_top_border" "$(repchar "$top_border" "$((BOXWIDTH-1))")" "$right_top_border"
}
boxbottom() {
echo -n "$left_bottom_border"
repchar "$bottom_border" $((BOXWIDTH-1))
echo -n "$right_bottom_border"
echo
boxbottom() {
printf "%s%s%s\n" "$left_bottom_border" "$(repchar "$bottom_border" "$((BOXWIDTH-1))")" "$right_bottom_border"
}
boxlinelog() {
logger printf "%s%s\r${ESC}[%sC%s\n" "$left_border" "$1" "$BOXWIDTH" "$right_border"
}
boxline(){
printf "%s%s\r${ESC}[%sC%s\n" "$left_border" "$1" "$BOXWIDTH" "$right_border"
}
boxseparator(){
printf '%s\n' "$(repchar "$box_break_line" $((BOXWIDTH-3)))"
}
boxborder() {
boxtop
for line in "$@" ; do
boxline "$line"
done
boxbottom
}
boxlinelog() {
@ -326,44 +313,48 @@ boxlinelog() {
logger echo -e "$left_border $_cmd\r${ESC}[${BOXWIDTH}C$right_border"
}
boxline(){
echo -e "$left_border $1\r${ESC}[${BOXWIDTH}C$right_border"
}
boxseparator(){
repchar "$box_break_line" $((BOXWIDTH-3))
echo
}
boxborder(){
boxtop
for line in "$@" ; do
boxline "$line"
done
boxbottom
}
boxborderlog(){
local _cmd=()
boxtop
for line in "$@" ; do
_cmd+=("$line")
done
for line in ${_cmd[@]} ; do
boxlinelog "$line"
done
boxbottom
}
subboxborder(){
BOXWIDTH_ORG=$BOXWIDTH
BOXWIDTH=$(($BOXWIDTH*75/100))
boxline $(boxtop)
for line in "$@" ; do
boxline $(boxline "$line")
subboxborder() {
level=${1:-0}
local indent=$((level*2))
local border_char="━"
local top_border=""
local bottom_border=""
# Set the border characters based on the level of nesting
if ((level==0)); then
left_border="$left_top_border"
right_border="$right_top_border"
top_border="$rep_char $border_char $indent"
bottom_border="$rep_char $border_char $indent"
else
left_border="$left_border"
right_border="$right_border"
top_border="$rep_char $border_char $indent"
bottom_border="$rep_char $border_char $indent"
fi
# Generate the top border
boxline "$(boxborder "$top_border")"
((level++))
# Generate the output lines
for line in "${@:2}" ; do
boxline "$(repchar " " $indent)$(boxline "$line")"
boxseparator
done
boxline $(boxbottom)
BOXWIDTH=$BOXWIDTH_ORG
# Generate the bottom border
((level--))
boxline "$(boxborder "$bottom_border")"
}
# # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
@ -429,26 +420,18 @@ run-and-log(){
fi
}
logger(){
if [ ! -z $logfile ] ; then
if [ ! -f $logfile ] ; then
#run mkdir -p ${rundir%/*}
touch $logfile
fi
"$@" 2>&1 | tee >(
while IFS= read -r line; do
# strip any escaped strings for logging output
_line=$(echo $line | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tr -dc '[:print:]')
# only print out non-empty lines to log
if [[ "$_line" != "" ]] ; then
printf '[%s] %s\n' "${scriptname}][${pretty_date}" "$_line"
fi
done >> $logfile
)
else
$@
fi
}
logger(){
if [[ -w "$logfile" ]]; then
"$@" 2>&1 | tee -a "$logfile" | while IFS= read -r line; do
# strip any escaped strings for logging output
_line="${line//[$'\t\r\x01-\x1F\x7F-\xFF']}"
# only print out non-empty lines to log
[[ -n $_line ]] && printf '[%s][%s] %s\n' "$scriptname" "$pretty_date" "$_line" >> "$logfile"
done
else
"$@"
fi
}
# File handling functions
@ -581,14 +564,14 @@ chained-grep(){
}
# Remove leading/trailing whitespace
trim() {
trim(){
local var=${@:2}
var="${var#"${var%%[![:space:]]*}"}"
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}
strip-html-tags() {
strip-html-tags(){
local input="$1"
local stripped=$(echo "$input" | sed 's/<[^>]*>//g' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo "$stripped"
@ -620,6 +603,22 @@ run-from-url(){
return $ec
}
check-git-repository(){
repodir=${1:-$rundir}
if [ -z $repodir ] ; then
warn "check-git-repository() Incorrect usage. Usage: check-git-repository </path/to/dir>"
return 2
fi
if git -C "$repodir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Directory '$repodir' is a valid Git repository."
return 0
# Your script logic here
else
echo "Directory '$repodir' is not a valid Git repository"
return 1
fi
}
# fancy script exits
ctrl_c(){
@ -628,38 +627,35 @@ ctrl_c(){
}
# Cosmetics
PRBL_LOGO="
${ESC}[38;5;202m_!*(xL}}xvr!,.${dfl}
${ESC}[38;5;202m>}KM3${ong}nLL}}}}}LLTh${ESC}[38;5;202m%5u>.${dfl}
${ESC}[38;5;202m<FE${ong}nvi${ESC}[38;5;202mT3Egg8888888DGn${ong}ivn${ESC}[38;5;202mOKr.${dfl}
${ESC}[38;5;202m.vEP${ong}?v${ESC}[38;5;202mZ88888${ong}Q${ESC}[38;5;178mB${ylw}B####B${ESC}[38;5;178mQ${ESC}[38;5;202m88888Zx${ong}rj${ESC}[38;5;202mNT.${dfl}
${ESC}[38;5;202m!MW${ong}^L${ESC}[38;5;202mD888${ESC}[38;5;178mQ${ylw}#@@${ESC}[38;5;178m@${ong}@${ESC}[38;5;202m######${ESC}[38;5;178m@${ylw}@@#B${ESC}[38;5;202m888g${ong}n>P${ESC}[38;5;202m8}.${dfl}
${ESC}[38;5;202m?g${ong}2!${ESC}[38;5;202m%888${ESC}[38;5;178mB${ylw}B${ESC}[38;5;178mev*${ong}<!!!!!!!!!>${ESC}[38;5;178m***^${ong}!!!!!.L${ESC}[38;5;202mB&?${dfl}
${ESC}[38;5;202m>gF${ong}=${ESC}[38;5;202mRg8${ong}8${ylw}#5${dfl} ${ESC}[38;5;202m,${ong}^}${ESC}[38;5;202m#Be-${dfl}
${ESC}[38;5;202mPg${ong}'${ESC}[38;5;202ma88${ong}8${ylw}#B ${ESC}[38;5;202m,unnnnn}- .ZO${ong}_${ESC}[38;5;202mN${ESC}[38;5;208m#B${ESC}[38;5;202mgr${dfl}
${ESC}[38;5;202m-gZ${ong}-${ESC}[38;5;202mg88${ong}8${ylw}B, ${ESC}[38;5;202m.U88${ong}!${ESC}[38;5;202mj${ESC}[38;5;208m#B#${ESC}[38;5;202m${ESC}[38;5;202mQs.${dfl}
${ESC}[38;5;202m.NM${ong}-${ESC}[38;5;202mD88${ong}N${ylw}! .${ESC}[38;5;202mj888${ong}=${ESC}[38;5;202mX${ESC}[38;5;208mQQ${ESC}[38;5;202mQ${ong}O${ESC}[38;5;202mQQ=${dfl}
${ESC}[38;5;202m28${ong}>u${ESC}[38;5;202m8g< ${ESC}[38;5;178m,${ong}!!!!!!!!!!!!!!!!${ESC}[38;5;178m>Lp${ESC}[38;5;202mQ888K${ong},${ESC}[38;5;202mQQ${ESC}[38;5;208mg${ESC}[38;5;202my ,V>${dfl}
${ESC}[38;5;202m_OM${ong}:K${ESC}[38;5;202m? ${ylw}.&#${ong}Q${ESC}[38;5;202m88888888888888${ESC}[38;5;178m#${ylw}@@${ESC}[38;5;178m#${ESC}[38;5;202m888M${ong}:p${ESC}[38;5;202m#${ESC}[38;5;208m#Q${ESC}[38;5;202m8G! .${dfl}
${ESC}[38;5;202m,WM${ong}!.!!${ESC}[38;5;202m^p${ESC}[38;5;178m#${ylw}@@${ESC}[38;5;178m#${ong}#${ESC}[38;5;202mQ88g8888Q${ong}B${ESC}[38;5;178m#${ylw}@@${ESC}[38;5;178m#Q${ESC}[38;5;202m888e${ong}!W${ESC}[38;5;202m#${ESC}[38;5;208m####${ESC}[38;5;202mBBg2!${dfl}
${ESC}[38;5;202m.u&n${ong}^y${ESC}[38;5;202mg88${ong}8${ESC}[38;5;178mQ${ylw}##@${ESC}[38;5;178m@${ong}@${ESC}[38;5;202m@@@${ong}@${ESC}[38;5;178m@@${ylw}@#${ESC}[38;5;178mB8${ong}8${ESC}[38;5;202m88K${ong}*}${ESC}[38;5;202mQ${ESC}[38;5;208m###${ESC}[38;5;202mBQ${ong}Q${ESC}[38;5;202mQ${ESC}[38;5;208mBB${ESC}[38;5;202m##gL.${dfl}
${ESC}[38;5;202m_nD${ong}j?${ESC}[38;5;202mxmPggg${ESC}[38;5;178m8${ylw}88Q${ESC}[38;5;178mQQQ${ylw}Q8${ESC}[38;5;178m88${ong}88${ESC}[38;5;202m8Wx${ong}?z${ESC}[38;5;202mQ${ESC}[38;5;208m#########${ESC}[38;5;202mQ${ESC}[38;5;208m#${ong}@${ESC}[38;5;202mQ8Z.${dfl}
${ESC}[38;5;202m.^y${ong}Oj${ESC}[38;5;202mLLL${ESC}[38;5;208m}${ESC}[38;5;202mjP${ong}%OEOM${ESC}[38;5;202m5suLxL${ong}jQ${ESC}[38;5;202m#${ESC}[38;5;208m######${ESC}[38;5;214mQ${ESC}[38;5;208m###${ESC}[38;5;202mB88&2${ong}vvn${ESC}[38;5;202mWQ(${dfl}
${ESC}[38;5;202m.!}${ong}%QQNWKessaG%gB${ESC}[38;5;202m###${ESC}[38;5;208m########${ESC}[38;5;202mB${ESC}[38;5;214mQ@@@${ESC}[38;5;208m#${ESC}[38;5;202mR?. r<${dfl}
${ESC}[38;5;202m.!LP${ESC}[38;5;208m8B${ESC}[38;5;214m##${ESC}[38;5;202m#Q${ong}5${ESC}[38;5;202mV%8${ESC}[38;5;208mB##B88${ong}QQ${ESC}[38;5;202mB${ESC}[38;5;208m##B${ESC}[38;5;202mB${ESC}[38;5;214m#@@@@@${ong}Q${ESC}[38;5;202me?,${dfl}
${ESC}[38;5;202m_*${ESC}[38;5;208mTW${ESC}[38;5;214m#${ESC}[38;5;202mP_ !K${ESC}[38;5;208mQ${ESC}[38;5;214m#${ESC}[38;5;202m@${ong}BM^^}${ESC}[38;5;202mOB${ESC}[38;5;208m##BB#${ESC}[38;5;202m#${ESC}[38;5;214m@@@#B${ESC}[38;5;202ma<${dfl}
${ESC}[38;5;202m-${ESC}[38;5;208m<${ESC}[38;5;202m!. :j${ESC}[38;5;208mg${ESC}[38;5;214m##${ESC}[38;5;202mh: _ry${ESC}[38;5;208mW8BBB${ESC}[38;5;202mB#${ESC}[38;5;214m#@@@@@${ESC}[38;5;202m#}.${dfl}
${ESC}[38;5;202m'!?${ESC}[38;5;214mn${ESC}[38;5;202mn?=. .-_,${ong}=${ESC}[38;5;202m^x${ESC}[38;5;214mAQ#@@${ESC}[38;5;202mB>${dfl}
${ESC}[38;5;202m>s${ESC}[38;5;214mQ@${ESC}[38;5;202m@?${dfl}
${ESC}[38;5;202m_n${ESC}[38;5;214mB${ESC}[38;5;202m#,${dfl}
${ESC}[38;5;202m-hv${dfl}
"
prbl-logo(){
echo -e \
"
_!*(xL}}xvr!,.
>}KM3nLL}}}}}LLTh%5u>.
<FEnviT3Egg8888888DGnivnOKr.
.vEP?vZ88888QBB####BQ88888ZxrjNT.
!MW^LD888Q#@@@@######@@@#B888gn>P8}.
?g2!%888BBev*<!!!!!!!!!>***^!!!!!.LB&?
>gF=Rg88#5 ,^}#Be-
Pg'a888#B ,unnnnn}- .ZO_N#Bgr
-gZ-g888B, .U88!j#B#Qs.
.NM-D88N! .j888=XQQQOQQ=
28>u8g< ,!!!!!!!!!!!!!!!!>LpQ888K,QQgy ,V>
_OM:K? .&#Q88888888888888#@@#888M:p##Q8G! .
,WM!.!!^p#@@##Q88g8888QB#@@#Q888e!W#####BBg2!
.u&n^yg888Q##@@@@@@@@@@#B8888K*}Q###BQQQBB##gL.
_nDj?xPggg888QQQQQ888888Wx?zQ####BQB88&2vvnWQ(
.^yOjLLL}jP%OEOM5suLxLjQ#######Q#@Q8Z. r<
.!}%QQNWKessaG%gB###########BQ@@@#R?.
.!LP8B###Q5V%8B##B88QQB##BB#@@@@@Qe?,
_*TW#P_ !KQ#@BM^^}OB##BB#@@@@@@@Ba<
-<!. :jg##h: _ryW8BBBB##@@@@@#}.
'!?nn?=. .-_,=^xAQ#@@B>
>sQ@@?
_nB#,
-hv
"
echo "${PRBL_LOGO}"
}
# ensure ctrl-c to cancel script ends the entire process and not just the current function
# trap ctrl_c INT # Commented out by default to prevent abnormal background exits
# Function for spinner status
# usage: spin "command [args]"
@ -1072,7 +1068,7 @@ check-prbl-version(){
vercomp
}
compare-versions() {
compare-versions(){
vercomp $1 $2
case $? in
0) op='=';;
@ -1087,4 +1083,101 @@ compare-versions() {
fi
}
set-boxtype
identify-system() {
if type lsb_release >/dev/null 2>&1; then
ID=$(lsb_release -si)
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/os-release ]; then
. /etc/os-release
ID=${ID:-$VERSION_ID}
ID=${ID:-$VERSION}
OS=$NAME
VER=$VERSION_ID
VER=${VER:-$VERSION}
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
ID=$DISTRIB_ID
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
VER=${VER:-$LSB_VERSION}
elif [ -f /etc/debian_version ]; then
ID=debian
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
OS=$(awk '{print $1}' /etc/redhat-release)
else
OS=$(uname -s)
VER=$(uname -r)
fi
}
ID() {
boxborder \
"ID: $ID" \
"OS: $OS" \
"VER: $VER"
}
install-packages() {
declare -a packages=()
declare -a offline_packages=()
for arg in "$@"; do
if [[ -f $arg ]]; then
offline_packages+=("$arg")
else
packages+=("$arg")
fi
done
identify-system
case $ID in
amzn | centos | fedora | rhel)
[ "${#packages[@]}" -gt 0 ] && run sudo yum install -y "${packages[@]}"
[ "${#offline_packages[@]}" -gt 0 ] && run sudo rpm -i "${packages[@]}"
;;
arch | Arch | manjaro)
if [ "${#packages[@]}" -gt 0 ]; then
run sudo pacman -Syu
run sudo pacman -S "${packages[@]}"
fi
[ "${#offline_packages[@]}" -gt 0 ] && run sudo pacman -U "${offline_packages[@]}"
;;
debian | ubuntu | Ubuntu)
if [ "${#packages[@]}" -gt 0 ]; then
run sudo apt-get update
run sudo apt-get install "${packages[@]}"
fi
[ "${#offline_packages[@]}" -gt 0 ] && run sudo dpkg -i "${offline_packages[@]}"
;;
opensuse | sles)
if [ "${#packages[@]}" -gt 0 ]; then
run sudo zypper refresh
run sudo zypper install "${packages[@]}"
fi
[ "${#offline_packages[@]}" -gt 0 ] && run sudo rpm -i "${offline_packages[@]}"
;;
slackware)
if [ "${#packages[@]}" -gt 0 ]; then
for package in "${packages[@]}"; do
run sudo installpkg "$package"
done
fi
if [ "${#offline_packages[@]}" -gt 0 ]; then
for package_file in "${offline_packages[@]}"; do
run sudo installpkg "$package_file"
done
fi
;;
brew)
[ "${#packages[@]}" -gt 0 ] && run brew install "${packages[@]}"
if [ "${#offline_packages[@]}" -gt 0 ]; then
for package_file in "${offline_packages[@]}"; do
run brew install "$package_file"
done
fi
;;
esac
}
set-boxtype