diff --git a/install.sh b/install.sh index 72ecec0..291976e 100755 --- a/install.sh +++ b/install.sh @@ -4,7 +4,7 @@ ################################################################### # initial vars -VERSION=1.1 +VERSION=2.0.0 scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION" rundir=${0%/*} source ${rundir}/functions @@ -181,10 +181,6 @@ userinstall(){ echo -e "$prbl_bashrc" >> $HOME/.bashrc.d/00-prbl.bashrc && boxborder "bashc.d/00-prbl installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc.d/00-prbl.bashrc${dfl}. Check this file for errors" fi - # Check crontab for quickinfo cron task - if [[ -z $(crontab -l | grep quickinfo) ]] ; then - crontab -l -u $runuser | cat - ${rundir}/lib/quickinfo.cron | crontab -u $runuser - && boxborder "QuickInfo cron task created." || warn "QuickInfo cron task creation failed. Check ${lbl}crontab -e${dfl} for errors" - fi # Create the quickinfo cache directory mkdir -p $HOME/.quickinfo @@ -250,11 +246,9 @@ globalinstall(){ if [[ $(cat /home/${selecteduser}/.bashrc | grep -c prbl) == 0 ]] ; then echo -e "$bashrc_append" >> /home/${selecteduser}/.bashrc && boxborder "bashc.d installed..." || warn "Malformed append on ${lbl}/home/${selecteduser}/.bashrc${dfl}. Check this file for errors" fi - crontab -l -u $selecteduser | cat - ${rundir}/lib/quickinfo.cron | crontab -u $selecteduser - - mkdir -p /home/${selecteduser}/.quickinfo chown -R ${selecteduser}:${selecteduser} /home/${selecteduser} if [[ "$bins_missing" == "false" ]] ; then - su ${selecteduser} -c /home/${selecteduser}.bashrc.d/11-quickinfo.bashrc -c + su ${selecteduser} -c /home/${selecteduser}.bashrc.d/11-quickinfo.bashrc fi fi done diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 9620b4f..78d1095 100644 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -9,22 +9,57 @@ # Written by Alan "pyr0ball" Weinstock # ############################################################### -# Preferences: - -# Network Adapter Preferences -show_disconnected=true -# separate adapter names with '\|' ex. "lo\|tun0" -filtered_adapters="lo" - -# Disks -# separate disk types with '\|' ex. "sd\|nvme" -allowed_disk_prefixes="sd\|md\|mapper\|nvme\|mmcblk\|root" -disallowed_disks="boot" - -# source PRbL functions -source $prbl_functions +quickinfo_version=2.0.0 prbl_functons_req_ver=1.1.3 +# 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 ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) +fi + +# source PRbL functions +if [ ! -z $prbl_functions ] ; then + source $prbl_functions +else + echo -e "PRbL functions not defined. Check ~/.bashrc" +fi + +settinsfile=$(echo "$rundir_abolute/${0##*/}" | cut -d '\.' -f1) +settinsfile="$settingfule.settings" +source $settingsfile + +# check PRbL functions version if [[ $(vercomp $functionsrev $prbl_functons_req_ver) == 2 ]] ; then warn "PRbL functions installed are lower than recommended ($prbl_functons_req_ver)" warn "Some features may not work as expected" @@ -35,67 +70,6 @@ else fi fi -# Cache File Parameters -cachefile=quickinfo.cache -cachefile_location=$HOME/.quickinfo -if [ ! -d $cachefile_location ] ; then - mkdir -p $cachefile_location -fi -cache=$(echo "${cachefile_location}/${cachefile}") - - -################################ - -quickinfo-cache (){ - # Uses a wide variety of methods to check which distro this is run on - 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 ", also works for BSD, etc. - OS=$(uname -s) - VER=$(uname -r) - fi - #check for updates - packages_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "can be") - supdates_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "security updates") - # Echo the parameters out to the cache file with a "key" marker - # at the beginning of the line. This key is used to pull the specific - # line needed for each parameter using grep, then cut out of the - # final echo. Please do not add or remove white space to the beginning of - # the lines if this is modified in future. - echo " - OS${OS} - VER${VER} - CACHEPACK${packages_cache} - CACHESUPD${supdates_cache}" > $cache || fail -} - ################################ # Help - displayed when user inputs the -h option, or upon @@ -143,22 +117,11 @@ while getopts ":cdh" opt # information to be displayed) #[[ "$-" == *i* ]] || fail "non-interactive session" -# Checks if cachefile exists yet, and if not, warns the user -if [ ! -f $cache ] ; then - cachemissing=$(echo "Quickinfo cache file is inaccessible. some information may be missing") -fi - -### All curl functions have been migrated to quickinfo-cache function - ################################ # Global parameters pulled from cache file - packages=$(cat ${cache} | grep CACHEPACK | cut -c 12- ) - supdates=$(cat ${cache} | grep CACHESUPD | cut -c 12- ) location=$(uname -a | awk '{print $2}') image_version=$(uname -r) - OS=$(cat ${cache} | grep OS | cut -c 5- ) - VER=$(cat ${cache} | grep VER | cut -c 6- ) software_version=$(echo $OS $VER) # Checks if variables are empty (due to webapp being down on last # cache run or other possible reasons) and fills the variables @@ -183,15 +146,12 @@ if [ -z "$cxps_serial" ] fi if [ "$any_missing" == "true" ] then - vars_missing=$(echo "Something went wrong gathering information. Check WebApp") + vars_missing=$(echo "Something went wrong gathering information") fi # Gets public IP address using opendns wan_ip=$(wget -qO- http://ipecho.net/plain | xargs echo) -# Global parameters using methods that do not require WebApp -### These functions run each time the script is run, regardless of caching option - # Checks memory usage mem_usage=$(free -m | grep Mem | awk '{print $3"M/"$2"M"}') diff --git a/lib/skel/.bashrc.d/11-quickinfo.settings b/lib/skel/.bashrc.d/11-quickinfo.settings new file mode 100644 index 0000000..837fcdd --- /dev/null +++ b/lib/skel/.bashrc.d/11-quickinfo.settings @@ -0,0 +1,13 @@ +# Network Adapter Preferences + +# set false to hide network adapters without valid IP's +show_disconnected=true + +# Ignored network adapter names (regex match) +# separate adapter names with '\|' ex. "lo\|tun0" +filtered_adapters="lo" + +# Disks +# separate disk types with '\|' ex. "sd\|nvme" +allowed_disk_prefixes="sd\|md\|mapper\|nvme\|mmcblk\|root" +disallowed_disks="boot"