added more comments, updated usage output
This commit is contained in:
parent
8500ec2a48
commit
fd8ddf0596
1 changed files with 42 additions and 12 deletions
54
install.sh
54
install.sh
|
|
@ -6,23 +6,39 @@
|
||||||
# initial vars
|
# initial vars
|
||||||
VERSION=2.2.0
|
VERSION=2.2.0
|
||||||
scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION"
|
scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION"
|
||||||
|
|
||||||
|
# Bash expansions to get the name and location of this script when run
|
||||||
scriptname="${BASH_SOURCE[0]##*/}"
|
scriptname="${BASH_SOURCE[0]##*/}"
|
||||||
rundir="${BASH_SOURCE[0]%/*}"
|
rundir="${BASH_SOURCE[0]%/*}"
|
||||||
|
|
||||||
|
# Source PRbL functions from installer directory
|
||||||
source ${rundir}/functions
|
source ${rundir}/functions
|
||||||
installer_functionsrev=$functionsrev
|
|
||||||
runuser=$(whoami)
|
|
||||||
users=($(ls /home/))
|
|
||||||
userinstalldir="$HOME/.local/share/prbl"
|
|
||||||
globalinstalldir="/usr/share/prbl"
|
|
||||||
bins_missing=()
|
|
||||||
backupFiles=()
|
|
||||||
installed_files=()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------#
|
#-----------------------------------------------------------------#
|
||||||
# Script-specific Parameters
|
# Script-specific Parameters
|
||||||
#-----------------------------------------------------------------#
|
#-----------------------------------------------------------------#
|
||||||
|
|
||||||
# List of dependency packaged to be istalled via apt
|
# Store functions revision in a variable to compare with if already installed
|
||||||
|
installer_functionsrev=$functionsrev
|
||||||
|
|
||||||
|
# Get and store the user currently executing this script
|
||||||
|
runuser=$(whoami)
|
||||||
|
|
||||||
|
# set up an array containing the users listed under /home/
|
||||||
|
users=($(ls /home/))
|
||||||
|
|
||||||
|
# If run as non-root, default install to user's home directory
|
||||||
|
userinstalldir="$HOME/.local/share/prbl"
|
||||||
|
|
||||||
|
# If run as root, this will be the install directory
|
||||||
|
globalinstalldir="/usr/share/prbl"
|
||||||
|
|
||||||
|
# Initialize arrays for file and dependency management
|
||||||
|
bins_missing=()
|
||||||
|
backupFiles=()
|
||||||
|
installed_files=()
|
||||||
|
|
||||||
|
# List of dependency packaged to be istalled via apt (For Debian/Ubuntu)
|
||||||
packages=(git
|
packages=(git
|
||||||
vim
|
vim
|
||||||
lm-sensors
|
lm-sensors
|
||||||
|
|
@ -69,6 +85,7 @@ if [[ $OS_DETECTED == "Debian" ]] || [[ $OS_DETECTED == "Ubuntu" ]]; then
|
||||||
packages+=(apt-config-auto-update)
|
packages+=(apt-config-auto-update)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# This variable is what is injected into the bashrc
|
||||||
bashrc_append="
|
bashrc_append="
|
||||||
# Pluggable bashrc config. Add environment modifications to ~/.bashrc.d/ and append with '.bashrc'
|
# Pluggable bashrc config. Add environment modifications to ~/.bashrc.d/ and append with '.bashrc'
|
||||||
if [ -n \"\$BASH_VERSION\" ]; then
|
if [ -n \"\$BASH_VERSION\" ]; then
|
||||||
|
|
@ -85,6 +102,7 @@ fi
|
||||||
# Script-specific Funcitons
|
# Script-specific Funcitons
|
||||||
#-----------------------------------------------------------------#
|
#-----------------------------------------------------------------#
|
||||||
|
|
||||||
|
# Function for displaying the usage of this script
|
||||||
usage(){
|
usage(){
|
||||||
boxborder \
|
boxborder \
|
||||||
"${lyl}$scripttitle${dfl}" \
|
"${lyl}$scripttitle${dfl}" \
|
||||||
|
|
@ -93,7 +111,11 @@ usage(){
|
||||||
"$(boxseparator)" \
|
"$(boxseparator)" \
|
||||||
"[args:]" \
|
"[args:]" \
|
||||||
" -i [--install]" \
|
" -i [--install]" \
|
||||||
|
" -d [--dependencies]" \
|
||||||
|
" -D [--dry-run]" \
|
||||||
" -r [--remove]" \
|
" -r [--remove]" \
|
||||||
|
" -f [--force]" \
|
||||||
|
" -F [--force-remove]" \
|
||||||
" -u [--update]" \
|
" -u [--update]" \
|
||||||
" -h [--help]" \
|
" -h [--help]" \
|
||||||
"" \
|
"" \
|
||||||
|
|
@ -102,6 +124,7 @@ usage(){
|
||||||
}
|
}
|
||||||
|
|
||||||
detectvim(){
|
detectvim(){
|
||||||
|
# If the vim install directory exists, check for and store the highest numerical value version installed
|
||||||
if [ -d /usr/share/vim ] ; then
|
if [ -d /usr/share/vim ] ; then
|
||||||
viminstall=$(ls -lah /usr/share/vim/ | grep vim | grep -v rc | awk '{print $NF}')
|
viminstall=$(ls -lah /usr/share/vim/ | grep vim | grep -v rc | awk '{print $NF}')
|
||||||
else
|
else
|
||||||
|
|
@ -111,15 +134,18 @@ detectvim(){
|
||||||
}
|
}
|
||||||
|
|
||||||
check-deps(){
|
check-deps(){
|
||||||
|
# Iterate through the list of required packages and check if installed
|
||||||
for pkg in ${packages[@]} ; do
|
for pkg in ${packages[@]} ; do
|
||||||
local _pkg=$(dpkg -l $pkg 2>&1 >/dev/null ; echo $?)
|
local _pkg=$(dpkg -l $pkg 2>&1 >/dev/null ; echo $?)
|
||||||
|
# If not installed, add it to the list of missing bins
|
||||||
if [[ $_pkg != 0 ]] ; then
|
if [[ $_pkg != 0 ]] ; then
|
||||||
bins_missing+=($pkg)
|
bins_missing+=($pkg)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
local _bins_missing=$(echo $bins_missing | wc -w)
|
# Count the number of entries in bins_missing
|
||||||
if [[ $_bins_missing == 0 ]] ; then
|
local _bins_missing=${#bins_missing[@]}
|
||||||
bins_missing=("false")
|
# If higher than 0, return a fail (1)
|
||||||
|
if [[ $_bins_missing != 0 ]] ; then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -131,18 +157,22 @@ install-deps(){
|
||||||
if [[ dry_run == true ]] ; then
|
if [[ dry_run == true ]] ; then
|
||||||
boxline "DryRun: spin \"for $_package in $packages ; do sudo apt=get install -y $_package ; done\""
|
boxline "DryRun: spin \"for $_package in $packages ; do sudo apt=get install -y $_package ; done\""
|
||||||
else
|
else
|
||||||
|
# using a spinner function block to track installation progress
|
||||||
spin "for $_package in $packages ; do sudo apt=get install -y $_package ; done"
|
spin "for $_package in $packages ; do sudo apt=get install -y $_package ; done"
|
||||||
fi
|
fi
|
||||||
|
# Sets dependency installed flag to true
|
||||||
depsinstalled=true
|
depsinstalled=true
|
||||||
}
|
}
|
||||||
|
|
||||||
install(){
|
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="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup
|
||||||
export prbl_functions=\"${installdir}/functions\""
|
export prbl_functions=\"${installdir}/functions\""
|
||||||
globalinstall
|
globalinstall
|
||||||
else
|
else
|
||||||
|
# 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="# Pyr0ball's Reductive Bash Library (PRbL) Functions library v$VERSION and greeting page setup
|
||||||
export prbl_functions=\"${installdir}/functions\""
|
export prbl_functions=\"${installdir}/functions\""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue