Merge pull request #5 from pyr0ball/develop

Pull latest fixes into main
This commit is contained in:
Alan Weinstock 2024-09-22 15:33:00 -07:00 committed by GitHub
commit 80c7bdd68c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 96 additions and 62 deletions

2
PRbL

@ -1 +1 @@
Subproject commit 396430c539486520f444fa3c6afb89e91c0dbbc8 Subproject commit 84e5100e9b3857db076f9469ff1f59c4fea65871

View file

@ -11,6 +11,11 @@ req_go_ver="1.19"
golang_bashrc="# Golang system path setup golang_bashrc="# Golang system path setup
export PATH=\$PATH:/usr/local/go/bin export PATH=\$PATH:/usr/local/go/bin
" "
if [[ $OSTYPE == linux-gnu ]] ; then
sys_type="linux"
else
sys_type="$OSTYPE"
fi
# Source PRbL Functions locally or retrieve from online # Source PRbL Functions locally or retrieve from online
if [ ! -z $prbl_functions ] ; then if [ ! -z $prbl_functions ] ; then
@ -140,7 +145,7 @@ install(){
esac esac
fi fi
local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_arch | grep $req_go_ver | head -n 1) local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_type | grep $sys_arch | grep $req_go_ver | head -n 1)
local golang_current=$(strip-html-tags "$_golang_html") local golang_current=$(strip-html-tags "$_golang_html")
#golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') #golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX` export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX`

View file

@ -66,6 +66,7 @@ packages=(
vim vim
lm-sensors lm-sensors
curl curl
net-tools
) )
# OS distribution auto-detection # OS distribution auto-detection
@ -187,14 +188,18 @@ install(){
# If script is run as root, run global install # If script is run as root, run global install
if [[ $runuser == root ]] ; then if [[ $runuser == root ]] ; then
installdir="${globalinstalldir}" installdir="${globalinstalldir}"
prbl_bashrc="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup prbl_bashrc="
export prbl_functions=\"${installdir}/functions\"" # Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup
export prbl_functions=\"${installdir}/functions\"
"
globalinstall globalinstall
else else
# If user is non-root, run user-level install # If user is non-root, run user-level install
installdir="${userinstalldir}" installdir="${userinstalldir}"
prbl_bashrc="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup prbl_bashrc="
export prbl_functions=\"${installdir}/functions\"" # Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup
export prbl_functions=\"${installdir}/functions\"
"
userinstall userinstall
fi fi
} }

View file

@ -0,0 +1,3 @@
alias updateAll="sudo apt-get update ; sudo apt-get upgrade -y ; sudo apt-get dist-upgrade -y ; sudo apt-get autoremove -y"
alias superlocate='bash -xc '\''ag -g $0 --hidden'\'' 2>/dev/null'
alias dirSize="du -h -d 1"

View file

@ -0,0 +1,5 @@
alias updateall="sudo apt-get update ; sudo apt-get upgrade -y ; sudo apt-get dist-upgrade -y ; sudo apt-get autoremove -y"
alias superlocate='bash -xc '\''ag -g $0 --hidden'\'' 2>/dev/null'
alias grabVideo='yt-dlp --output "%(title)s.%(ext)s" --restrict-filenames --write-sub --sub-lang en --convert-subs srt --write-auto-sub'
alias grabAudio='yt-dlp --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames'
alias grabAlbum='yt-dlp --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" --restrict-filenames --split-chapters'

View file

@ -9,48 +9,9 @@
# Written by Alan "pyr0ball" Weinstock # # Written by Alan "pyr0ball" Weinstock #
############################################################### ###############################################################
quickinfo_version=2.1.0 quickinfo_version=2.1.1
prbl_functons_req_ver=1.6.0 prbl_functons_req_ver=1.6.0
# Uses a wide variety of methods to check which distro this is run on
# TODO: Add alternative handling for other environments
if type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# If running on login as a bashrc, the above variables will not give this script's data
# Failover hardcoded settings location for now if running from login environment
# TODO: Need to re-test after v2.2.x # TODO: Need to re-test after v2.2.x
### TODO: This implementation is still broken. context for location breaks during login ### TODO: This implementation is still broken. context for location breaks during login
@ -62,7 +23,10 @@ fi
# if ! [ -f "$HOME/.bashrc.d/11-quickinfo.settings"] ; then # if ! [ -f "$HOME/.bashrc.d/11-quickinfo.settings"] ; then
# settingsfile="$HOME/.bashrc.d/11-quickinfo.settings" # settingsfile="$HOME/.bashrc.d/11-quickinfo.settings"
# else # else
# default quickinfo bashrc Preferences
########################################
# Default quickinfo bashrc Preferences #
########################################
# Disable run on non-interactive sessions (set true to disable) # Disable run on non-interactive sessions (set true to disable)
interactive_only=false interactive_only=false
@ -77,25 +41,76 @@ fi
filtered_adapters="lo" filtered_adapters="lo"
# Disks # Disks
# separate disk types with '\|' ex. "sd\|nvme"
allowed_disk_prefixes="sd\|md\|mapper\|nvme\|mmcblk\|root" allowed_disk_prefixes=(
disallowed_disks="boot" sd
md
mapper
nvme
mmcblk
root
)
disallowed_disk_prefixes=(
boot
)
#######################################################
# Do not change these unless you know what you're doing
# convert array to grep string
for prefix in "${allowed_disk_prefixes[@]}" ; do
allowed_disk_prefixes_string+="\\|$prefix"
done
# Remove the leading '\|' from the grep string
allowed_disk_prefixes_string="${allowed_disk_prefixes_string:2}"
# Manual regex string
# To use, uncomment and separate disk types with '\|' ex. "sd\|nvme"
# or use any other grep-compatible filtering desired
#allowed_disk_prefixes_string="sd\|md\|mapper\|nvme\|mmcblk\|root"
for prefix in "${disallowed_disk_prefixes[@]}" ; do
disallowed_disk_prefixes_string+="\\|$prefix"
done
disallowed_disk_prefixes_string="${allowed_disk_prefixes_string:2}"
# fi # fi
# fi # fi
# source $settingsfile # source $settingsfile
# source PRbL functions # source PRbL functions
# Source PRbL Functions locally or retrieve from online
if [ ! -z $prbl_functions ] ; then if [ ! -z $prbl_functions ] ; then
source $prbl_functions source $prbl_functions
else else
# Failover if global variable is not defined. Checks for 'functions' in same location if [ -f ${rundir}/functions ] ; then
echo -e "PRbL functions not defined. Check ~/.bashrc" source ${rundir}/functions
if [ -f "${BASH_SOURCE[0]%/*}/functions" ] ; then
source ${BASH_SOURCE[0]%/*}/functions
else else
echo -e "local functions file also missing. Some visual elements will be missing" # Iterate through get commands and fall back on next if unavailable
if command -v curl >/dev/null 2>&1; then
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v wget >/dev/null 2>&1; then
source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v fetch >/dev/null 2>&1; then
source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
else
echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions."
exit 1
fi
fi fi
fi fi
# if [ ! -z $prbl_functions ] ; then
# source $prbl_functions
# else
# # Failover if global variable is not defined. Checks for 'functions' in same location
# echo -e "PRbL functions not defined. Check ~/.bashrc"
# if [ -f "${BASH_SOURCE[0]%/*}/functions" ] ; then
# source $rundir/functions
# else
# echo -e "local functions file also missing. Some visual elements will be missing"
# fi
# fi
# Locate and import settings (shares same name with script apart from file extension) # Locate and import settings (shares same name with script apart from file extension)
scriptname="${BASH_SOURCE[0]##*/}" scriptname="${BASH_SOURCE[0]##*/}"
rundir="${BASH_SOURCE[0]%/*}" rundir="${BASH_SOURCE[0]%/*}"
@ -179,6 +194,7 @@ fi
# TODO: optimize this to run after time delay using timestamp in settings # TODO: optimize this to run after time delay using timestamp in settings
set_spinner spinner19 set_spinner spinner19
#spin "eval $(wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo ))" #spin "eval $(wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo ))"
#spin read -r wan_ip < <(wget -qO- http://ipecho.net/plain \| xargs echo)
wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo ) wan_ip=$(wget -qO- http://ipecho.net/plain \| xargs echo )
#spin read -r wan_ip < <(wget -qO- https://ident.me/) #spin read -r wan_ip < <(wget -qO- https://ident.me/)
@ -279,7 +295,7 @@ declare -a macs=()
declare -a ifups=() declare -a ifups=()
for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do
adapters+=($device) adapters+=($device)
_ip=$(ip -f inet -o addr show $device | cut -d\ -f 7 | cut -d/ -f 1 | head -n 1) _ip=$(ip -o -f inet addr show $device | awk '{print $4}' | cut -d/ -f 1 | head -n 1)
if valid-ip $_ip ; then if valid-ip $_ip ; then
ips+=("$_ip") ips+=("$_ip")
ifups+=("up") ifups+=("up")
@ -297,7 +313,7 @@ declare -a logicals=()
declare -a mounts=() declare -a mounts=()
declare -a usages=() declare -a usages=()
declare -a freespaces=() declare -a freespaces=()
diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes" | grep -v "$disallowed_disks") diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes_string" | grep -v "$disallowed_disk_prefixes_string")
logicals=($(cut -d ' ' -f1 <<< "${diskinfo}")) logicals=($(cut -d ' ' -f1 <<< "${diskinfo}"))
mounts=($(awk '{print $6}' <<< "${diskinfo}")) mounts=($(awk '{print $6}' <<< "${diskinfo}"))
usages=($(awk '{print $5}' <<< "${diskinfo}")) usages=($(awk '{print $5}' <<< "${diskinfo}"))
@ -326,7 +342,7 @@ boxline ""
boxline "${bld}${unl}Location:${dfl} ${grn}${unl}$location${dfl}" boxline "${bld}${unl}Location:${dfl} ${grn}${unl}$location${dfl}"
boxline "" boxline ""
# Echo out network arrays # Echo out network arrays
for ((i=0; i<"${#adapters[@]}"; i++ )); do for ((i=0; i<"${#adapters[@]}"; i++ )) ; do
if [[ $show_disconnected != true ]] ; then if [[ $show_disconnected != true ]] ; then
if [[ ${ifups[$i]} == up ]] ; then if [[ ${ifups[$i]} == up ]] ; then
boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl} | ${blu}${macs[$i]}${dfl}" boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl} | ${blu}${macs[$i]}${dfl}"
@ -346,7 +362,7 @@ boxline " CPU Temp: ${lbl}${cputemp}${dfl} | Utilization: ${lrd}${cpu_util}%${d
boxline " Memory used/total: ${mem_usage}" boxline " Memory used/total: ${mem_usage}"
boxline " ${unl}Disk Info:${dfl}" boxline " ${unl}Disk Info:${dfl}"
boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Volumes)${dfl}" boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Volumes)${dfl}"
for ((i=0; i<"${#logicals[@]}"; i++ )); do for ((i=0; i<"${#logicals[@]}" ; i++ )) ; do
boxline " $(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})" boxline " $(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})"
done done
boxline "" boxline ""