version 2.0.0, refactored out cache, introduced external settings file
This commit is contained in:
parent
7e2060a53e
commit
fbb7b0b468
3 changed files with 65 additions and 98 deletions
10
install.sh
10
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
|
||||
|
|
|
|||
|
|
@ -9,45 +9,11 @@
|
|||
# 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
|
||||
|
||||
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"
|
||||
else
|
||||
if ! vercomp 1 1 ; then
|
||||
warn "PRbL functions library is older than 1.1.3, please update!"
|
||||
warn "Some features may not work as expected"
|
||||
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
|
||||
# TODO: Add alternative handling for other environments
|
||||
if type lsb_release >/dev/null 2>&1; then
|
||||
# linuxbase.org
|
||||
OS=$(lsb_release -si)
|
||||
|
|
@ -81,20 +47,28 @@ quickinfo-cache (){
|
|||
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
|
||||
}
|
||||
|
||||
# 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"
|
||||
else
|
||||
if ! vercomp 1 1 ; then
|
||||
warn "PRbL functions library is older than 1.1.3, please update!"
|
||||
warn "Some features may not work as expected"
|
||||
fi
|
||||
fi
|
||||
|
||||
################################
|
||||
|
||||
|
|
@ -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"}')
|
||||
|
||||
|
|
|
|||
13
lib/skel/.bashrc.d/11-quickinfo.settings
Normal file
13
lib/skel/.bashrc.d/11-quickinfo.settings
Normal file
|
|
@ -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"
|
||||
Loading…
Reference in a new issue