Merge pull request #1 from pyr0ball/newfeature_extras_menu
Newfeature extras menu
This commit is contained in:
commit
fd17a2410c
3 changed files with 155 additions and 287 deletions
|
|
@ -4,18 +4,18 @@
|
||||||
# Bash expansions to get the name and location of this script when run
|
# 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]%/*}"
|
||||||
logfile
|
|
||||||
|
|
||||||
# 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
|
||||||
source $prbl_functions
|
source $prbl_functions
|
||||||
else
|
else
|
||||||
curl -k 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions' > $rundir/functions
|
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions')
|
||||||
source $rundir/functions
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
logfile="${rundir}/${pretty_date}_${scriptname}.log"
|
||||||
installdir="$HOME/devl"
|
installdir="$HOME/devl"
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
sys_packages=(
|
sys_packages=(
|
||||||
git
|
git
|
||||||
curl
|
curl
|
||||||
|
|
@ -36,17 +36,7 @@ repo_packages=(
|
||||||
codedog_bashrc="# CodeDog system path setup
|
codedog_bashrc="# CodeDog system path setup
|
||||||
export PATH=\"\$PATH:\$HOME/devl/CodeDog\"
|
export PATH=\"\$PATH:\$HOME/devl/CodeDog\"
|
||||||
"
|
"
|
||||||
|
# Functions
|
||||||
run(){
|
|
||||||
_cmd=$@
|
|
||||||
if [[ dry_run == true ]] ; then
|
|
||||||
boxline "DryRun: $_cmd"
|
|
||||||
else
|
|
||||||
boxline "not a dry run"
|
|
||||||
$_cmd
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check-deps(){
|
check-deps(){
|
||||||
# Iterate through the list of required packages and check if installed
|
# Iterate through the list of required packages and check if installed
|
||||||
for pkg in ${packages[@]} ; do
|
for pkg in ${packages[@]} ; do
|
||||||
|
|
@ -67,131 +57,19 @@ check-deps(){
|
||||||
}
|
}
|
||||||
|
|
||||||
install-deps(){
|
install-deps(){
|
||||||
boxborder "Installing packages $packages"
|
logger echo "Installing packages $sys_packages"
|
||||||
run "for $_package in $packages ; do sudo apt-get install -y $_package ; done"
|
run "for $_package in $sys_packages ; do sudo apt-get install -y $_package ; done"
|
||||||
|
if [ -f ${rundir}/requirements.txt ] ; then
|
||||||
|
pip install -y ${rundir}/requirements.txt
|
||||||
|
else
|
||||||
|
if [ ! -z $pip_packages ] ; then
|
||||||
|
pip install -y ${pip_packages[@]}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Sets dependency installed flag to true
|
# Sets dependency installed flag to true
|
||||||
depsinstalled=true
|
depsinstalled=true
|
||||||
}
|
}
|
||||||
|
|
||||||
take-backup(){
|
|
||||||
name="$1"
|
|
||||||
if [[ $update_run != true ]] ; then
|
|
||||||
if [[ $dry_run == true ]] ; then
|
|
||||||
# Check if a backup file or symbolic link already exists
|
|
||||||
if [[ -e "$name.bak" || -L "$name.bak" ]]; then
|
|
||||||
boxline "DryRun: $name.bak backup already exists"
|
|
||||||
else
|
|
||||||
# Check if the file is a hidden file (starts with a dot)
|
|
||||||
if [[ "$name" == .* ]]; then
|
|
||||||
# Add a dot to the beginning of the backup file name
|
|
||||||
backup_name=".${name}.bak"
|
|
||||||
else
|
|
||||||
# Create the backup file name by appending ".bak" to the original file name
|
|
||||||
backup_name="${name}.bak"
|
|
||||||
fi
|
|
||||||
# Copy the file to the backup file with preservation of file attributes
|
|
||||||
boxline "DryRun: cp -p $name $backup_name"
|
|
||||||
# Add the original file to the list of backup files
|
|
||||||
backup_files+=("$name")
|
|
||||||
# Log the original file name to the backup file list file
|
|
||||||
boxline "DryRun: echo $name >> $rundir/backup_files.list"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Check if a backup file or symbolic link already exists
|
|
||||||
if [[ -e "$name.bak" || -L "$name.bak" ]]; then
|
|
||||||
boxline " $name.bak backup already exists"
|
|
||||||
else
|
|
||||||
# Check if the file is a hidden file (starts with a dot)
|
|
||||||
if [[ "$name" == .* ]]; then
|
|
||||||
# Add a dot to the beginning of the backup file name
|
|
||||||
backup_name=".${name}.bak"
|
|
||||||
else
|
|
||||||
# Create the backup file name by appending ".bak" to the original file name
|
|
||||||
backup_name="${name}.bak"
|
|
||||||
fi
|
|
||||||
# Copy the file to the backup file with preservation of file attributes
|
|
||||||
cp -p "$name" "$backup_name"
|
|
||||||
# Add the original file to the list of backup files
|
|
||||||
backup_files+=("$name")
|
|
||||||
# Log the original file name to the backup file list file
|
|
||||||
boxline "$name" >> "$rundir/backup_files.list"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
restore-backup(){
|
|
||||||
echo "${#backup_files[@]}"
|
|
||||||
for file in "${backup_files[@]}" ; do
|
|
||||||
cp "$file".bak $file
|
|
||||||
echo "$file is restored"
|
|
||||||
done
|
|
||||||
backup_files=()
|
|
||||||
if [ -f $rundir/backup_files.list ] ; then
|
|
||||||
rm $rundir/backup_files.list
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install-file(){
|
|
||||||
local _source="$1"
|
|
||||||
local _destination="$2"
|
|
||||||
local _source_root="$3"
|
|
||||||
local _filename=${_source##*/}
|
|
||||||
local _destination_file=${_destination}/${_filename#${_source_root}}
|
|
||||||
installed_files+=("${_destination_file}")
|
|
||||||
if [[ $update_run == true ]] ; then
|
|
||||||
boxline "$scriptname: added file ${_destination_file} to list"
|
|
||||||
else
|
|
||||||
if [[ $dry_run == true ]] ; then
|
|
||||||
boxline "DryRun: cp -p $_source $_destination_file"
|
|
||||||
else
|
|
||||||
cp -p $_source $_destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
|
||||||
fi
|
|
||||||
echo "${_destination_file}" >> $rundir/installed_files.list
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install-dir() {
|
|
||||||
local _source="$1"
|
|
||||||
local _destination="$2"
|
|
||||||
installed_dirs+=("$_source -> $_destination")
|
|
||||||
# Iterate through all files in the source directory recursively
|
|
||||||
while IFS= read -r -d '' source_file; do
|
|
||||||
# Construct the destination file path by removing the source directory path
|
|
||||||
# and appending it to the destination directory path
|
|
||||||
local _filename="${source_file#${_source}}"
|
|
||||||
local destination_file="${_destination}/${source_file#${_source}}"
|
|
||||||
# Create the parent directory of the destination file if it doesn't exist
|
|
||||||
# Log the destination file path to the logfile
|
|
||||||
#echo "$destination_file" >> "$logfile"
|
|
||||||
installed_files+=($destination_file)
|
|
||||||
if [[ $update_run == true ]] ; then
|
|
||||||
boxline "$scriptname: added file ${destination_file} to list"
|
|
||||||
else
|
|
||||||
if [[ $dry_run == true ]] ; then
|
|
||||||
# Create the destination directory if it doesn't exist
|
|
||||||
boxline "DryRun: mkdir -p $(dirname $destination_file)"
|
|
||||||
boxline "DryRun: cp -p ${_source}${_filename} $destination_file"
|
|
||||||
else
|
|
||||||
# Create the destination directory if it doesn't exist
|
|
||||||
mkdir -p "$(dirname "$destination_file")"
|
|
||||||
cp -p ${_source}${_filename} $destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
|
||||||
fi
|
|
||||||
echo "${destination_file}" >> $rundir/installed_files.list
|
|
||||||
fi
|
|
||||||
done < <(find "$_source" -type f -print0)
|
|
||||||
}
|
|
||||||
|
|
||||||
clone-repo(){
|
|
||||||
# git clone <source url> <destination>
|
|
||||||
local _url=$1
|
|
||||||
local _destination=$2
|
|
||||||
if [ ! -z $_destination ] ; then
|
|
||||||
mkdir -p $_destination
|
|
||||||
fi
|
|
||||||
git clone --recurse-submodules $_url $_destination
|
|
||||||
}
|
|
||||||
|
|
||||||
dry-run-report(){
|
dry-run-report(){
|
||||||
box-rounded
|
box-rounded
|
||||||
boxborder "${grn}Dry-run Report:${dfl}"
|
boxborder "${grn}Dry-run Report:${dfl}"
|
||||||
|
|
@ -213,11 +91,11 @@ install(){
|
||||||
export PATH="$PATH:$HOME/devl/CodeDog"
|
export PATH="$PATH:$HOME/devl/CodeDog"
|
||||||
# Check for dependent applications and offer to install
|
# Check for dependent applications and offer to install
|
||||||
if ! check-deps ; then
|
if ! check-deps ; then
|
||||||
run warn "Some of the utilities needed by this script are missing"
|
warn "Some of the utilities needed by this install are missing"
|
||||||
boxtop
|
boxtop
|
||||||
run boxline "Missing utilities:"
|
logger echo -e "Missing utilities:"
|
||||||
for bin in ${bins_missing[@]} ; do
|
for bin in ${bins_missing[@]} ; do
|
||||||
run boxline "${bins_missing[$bin]}"
|
logger echo -e "${bins_missing[$bin]}"
|
||||||
done
|
done
|
||||||
boxbottom
|
boxbottom
|
||||||
boxborder "Would you like to install them? (this will require root password)"
|
boxborder "Would you like to install them? (this will require root password)"
|
||||||
|
|
@ -227,54 +105,70 @@ install(){
|
||||||
)
|
)
|
||||||
case `select_opt "${utilsmissing_menu[@]}"` in
|
case `select_opt "${utilsmissing_menu[@]}"` in
|
||||||
0) boxborder "${grn}Installing dependencies...${dfl}"
|
0) boxborder "${grn}Installing dependencies...${dfl}"
|
||||||
run sudo install-deps
|
install-deps
|
||||||
;;
|
;;
|
||||||
1) run warn "Dependent Utilities missing: $bins_missing" ;;
|
1) warn "Dependent Utilities missing: $bins_missing" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
run mkdir -p $installdir
|
run mkdir -p $installdir
|
||||||
pushd $installdir
|
pushd $installdir
|
||||||
for repo in $repo_packages ; do
|
for repo in ${repo_packages[@]} ; do
|
||||||
run clone-repo $repo
|
clone-repo $repo
|
||||||
done
|
done
|
||||||
popd
|
popd
|
||||||
pushd $installdir/Proteus
|
pushd $installdir/Proteus
|
||||||
run sudo python3 ruleMgr.py
|
run sudo python3 ruleMgr.py
|
||||||
popd
|
popd
|
||||||
pushd $installdir/Slipstream
|
pushd $installdir/Slipstream
|
||||||
run codeDog ./Slipstream.dog && success "Slipstream app built at ${installdir}/Slipstream/LinuxBuild"
|
run $installdir/CodeDog/codeDog ./Slipstream.dog && logger echo "Slipstream app built at ${installdir}/Slipstream/LinuxBuild"
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function for displaying the usage of this script
|
||||||
|
usage(){
|
||||||
|
boxborder \
|
||||||
|
"${lbl}Usage:${dfl}" \
|
||||||
|
"${lyl}./$scriptname ${bld}[args]${dfl}" \
|
||||||
|
"$(boxseparator)" \
|
||||||
|
"[args:]" \
|
||||||
|
" -i [--install]" \
|
||||||
|
" -d [--dependencies]" \
|
||||||
|
" -D [--dry-run]" \
|
||||||
|
" -r [--remove]" \
|
||||||
|
" -f [--force]" \
|
||||||
|
" -F [--force-remove]" \
|
||||||
|
" -u [--update]" \
|
||||||
|
" -h [--help]"
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
-i | --install)
|
-i | --install)
|
||||||
install && success " [${red}P${lrd}R${ylw}b${ong}L ${lyl}Installed${dfl}]"
|
install && success " [${lbl}Slip${gry}Stream ${lyl}Installed${dfl}]"
|
||||||
;;
|
;;
|
||||||
-r | --remove)
|
-r | --remove)
|
||||||
remove && success " [${red}P${lrd}R${ylw}b${ong}L ${lyl}Removed${dfl}]"
|
remove && success " [${lbl}Slip${gry}Stream ${lyl}Removed${dfl}]"
|
||||||
;;
|
;;
|
||||||
-d | --dependencies)
|
-d | --dependencies)
|
||||||
install-deps && success "${red}P${lrd}R${ylw}b${ong}L${dfl} Dependencies installed!"
|
install-deps && success "${lbl}Slip${gry}Stream ${dfl} Dependencies installed!"
|
||||||
;;
|
;;
|
||||||
-D | --dry-run)
|
-D | --dry-run)
|
||||||
export dry_run=true
|
export dry_run=true
|
||||||
echo dry_run=$dry_run
|
|
||||||
install
|
install
|
||||||
dry-run-report
|
dry-run-report
|
||||||
usage
|
usage
|
||||||
unset dry_run
|
unset dry_run
|
||||||
success "${red}P${lrd}R${ylw}b${ong}L${dfl} Dry-Run Complete!"
|
success "${lbl}Slip${gry}Stream ${lyl}Installer Dry-Run Complete!${dfl}"
|
||||||
;;
|
;;
|
||||||
-u | --update)
|
-u | --update)
|
||||||
export update_run=true
|
export update_run=true
|
||||||
update && unset update_run && success " [${red}P${lrd}R${ylw}b${ong}L ${lyl}Updated${dfl}]"
|
update && unset update_run && success " [${lbl}Slip${gry}Stream ${lyl}Updated${dfl}]"
|
||||||
;;
|
;;
|
||||||
-f | --force)
|
-f | --force)
|
||||||
remove-arbitrary
|
remove-arbitrary
|
||||||
install && success " [${red}P${lrd}R${ylw}b${ong}L ${lyl}Installed${dfl}]"
|
install && success " [${lbl}Slip${blu}Stream ${lyl}Installed${dfl}]"
|
||||||
;;
|
;;
|
||||||
-F | --force-remove)
|
-F | --force-remove)
|
||||||
remove-arbitrary && success " [${red}P${lrd}R${ylw}b${ong}L ${lyl}Force-Removed${dfl}]"
|
remove-arbitrary && success " [${lbl}Slip${gry}Stream ${lyl}Force-Removed${dfl}]"
|
||||||
;;
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
usage
|
usage
|
||||||
|
|
|
||||||
210
install.sh
210
install.sh
|
|
@ -4,16 +4,28 @@
|
||||||
###################################################################
|
###################################################################
|
||||||
|
|
||||||
# initial vars
|
# initial vars
|
||||||
VERSION=2.2.0
|
VERSION=2.2.2
|
||||||
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
|
# 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 PRbL functions from installer directory
|
||||||
|
# Source PRbL Functions locally or retrieve from online
|
||||||
|
# TODO: Add version check to this
|
||||||
|
if [ ! -z $prbl_functions ] ; then
|
||||||
|
source $prbl_functions
|
||||||
|
else
|
||||||
|
if [ -f ${rundir}/functions ] ; then
|
||||||
|
source ${rundir}/functions
|
||||||
|
else
|
||||||
|
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rundir_absolute=$(pushd $rundir ; pwd ; popd)
|
||||||
|
logfile="${rundir}/${pretty_date}_${scriptname}.log"
|
||||||
#-----------------------------------------------------------------#
|
#-----------------------------------------------------------------#
|
||||||
# Script-specific Parameters
|
# Script-specific Parameters
|
||||||
#-----------------------------------------------------------------#
|
#-----------------------------------------------------------------#
|
||||||
|
|
@ -133,28 +145,10 @@ usage(){
|
||||||
"You must run as 'root' for this script to automatically resolve dependencies"
|
"You must run as 'root' for this script to automatically resolve dependencies"
|
||||||
}
|
}
|
||||||
|
|
||||||
run(){
|
|
||||||
_cmd=$@
|
|
||||||
if [[ dry_run == true ]] ; then
|
|
||||||
boxline "DryRun: $_cmd"
|
|
||||||
else
|
|
||||||
$_cmd
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
run-and-log(){
|
|
||||||
_cmd=$@
|
|
||||||
if [[ dry_run == true ]] ; then
|
|
||||||
logger "DryRun: $_cmd"
|
|
||||||
else
|
|
||||||
logger $_cmd
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
detectvim(){
|
detectvim(){
|
||||||
# If the vim install directory exists, check for and store the highest numerical value version installed
|
# 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}' | tail -n 1)
|
||||||
else
|
else
|
||||||
viminstall=null
|
viminstall=null
|
||||||
warn "vim is not currently installed, unable to set up colorscheme and formatting"
|
warn "vim is not currently installed, unable to set up colorscheme and formatting"
|
||||||
|
|
@ -183,7 +177,7 @@ check-deps(){
|
||||||
install-deps(){
|
install-deps(){
|
||||||
boxborder "Installing packages $packages"
|
boxborder "Installing packages $packages"
|
||||||
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
|
# 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"
|
||||||
|
|
@ -211,10 +205,9 @@ export prbl_functions=\"${installdir}/functions\""
|
||||||
take-backup(){
|
take-backup(){
|
||||||
name="$1"
|
name="$1"
|
||||||
if [[ $update_run != true ]] ; then
|
if [[ $update_run != true ]] ; then
|
||||||
if [[ $dry_run == true ]] ; then
|
|
||||||
# Check if a backup file or symbolic link already exists
|
# Check if a backup file or symbolic link already exists
|
||||||
if [[ -e "$name.bak" || -L "$name.bak" ]]; then
|
if [[ -e "$name.bak" || -L "$name.bak" ]]; then
|
||||||
boxline "DryRun: $name.bak backup already exists"
|
run boxline " $name.bak backup already exists"
|
||||||
else
|
else
|
||||||
# Check if the file is a hidden file (starts with a dot)
|
# Check if the file is a hidden file (starts with a dot)
|
||||||
if [[ "$name" == .* ]]; then
|
if [[ "$name" == .* ]]; then
|
||||||
|
|
@ -225,45 +218,24 @@ take-backup(){
|
||||||
backup_name="${name}.bak"
|
backup_name="${name}.bak"
|
||||||
fi
|
fi
|
||||||
# Copy the file to the backup file with preservation of file attributes
|
# Copy the file to the backup file with preservation of file attributes
|
||||||
boxline "DryRun: cp -p $name $backup_name"
|
run cp -p "$name" "$backup_name"
|
||||||
# Add the original file to the list of backup files
|
# Add the original file to the list of backup files
|
||||||
backup_files+=("$name")
|
backup_files+=("$name")
|
||||||
# Log the original file name to the backup file list file
|
# Log the original file name to the backup file list file
|
||||||
boxline "DryRun: echo $name >> $rundir/backup_files.list"
|
run echo "$name" >> "$rundir/backup_files.list"
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Check if a backup file or symbolic link already exists
|
|
||||||
if [[ -e "$name.bak" || -L "$name.bak" ]]; then
|
|
||||||
boxline " $name.bak backup already exists"
|
|
||||||
else
|
|
||||||
# Check if the file is a hidden file (starts with a dot)
|
|
||||||
if [[ "$name" == .* ]]; then
|
|
||||||
# Add a dot to the beginning of the backup file name
|
|
||||||
backup_name=".${name}.bak"
|
|
||||||
else
|
|
||||||
# Create the backup file name by appending ".bak" to the original file name
|
|
||||||
backup_name="${name}.bak"
|
|
||||||
fi
|
|
||||||
# Copy the file to the backup file with preservation of file attributes
|
|
||||||
cp -p "$name" "$backup_name"
|
|
||||||
# Add the original file to the list of backup files
|
|
||||||
backup_files+=("$name")
|
|
||||||
# Log the original file name to the backup file list file
|
|
||||||
boxline "$name" >> "$rundir/backup_files.list"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restore-backup(){
|
restore-backup(){
|
||||||
echo "${#backup_files[@]}"
|
run echo "${#backup_files[@]}"
|
||||||
for file in "${backup_files[@]}" ; do
|
for file in "${backup_files[@]}" ; do
|
||||||
cp "$file".bak $file
|
run cp "$file".bak $file
|
||||||
echo "$file is restored"
|
run echo "$file is restored"
|
||||||
done
|
done
|
||||||
backup_files=()
|
backup_files=()
|
||||||
if [ -f $rundir/backup_files.list ] ; then
|
if [ -f $rundir/backup_files.list ] ; then
|
||||||
rm $rundir/backup_files.list
|
run rm $rundir/backup_files.list
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,14 +247,10 @@ install-file(){
|
||||||
local _destination_file=${_destination}/${_filename#${_source_root}}
|
local _destination_file=${_destination}/${_filename#${_source_root}}
|
||||||
installed_files+=("${_destination_file}")
|
installed_files+=("${_destination_file}")
|
||||||
if [[ $update_run == true ]] ; then
|
if [[ $update_run == true ]] ; then
|
||||||
boxline "$scriptname: added file ${_destination_file} to list"
|
run boxline "$scriptname: added file ${_destination_file} to list"
|
||||||
else
|
else
|
||||||
if [[ $dry_run == true ]] ; then
|
run cp -p $_source $_destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
||||||
boxline "DryRun: cp -p $_source $_destination_file"
|
run echo "${_destination_file}" >> $rundir/installed_files.list
|
||||||
else
|
|
||||||
cp -p $_source $_destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
|
||||||
fi
|
|
||||||
echo "${_destination_file}" >> $rundir/installed_files.list
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,49 +269,66 @@ install-dir() {
|
||||||
#echo "$destination_file" >> "$logfile"
|
#echo "$destination_file" >> "$logfile"
|
||||||
installed_files+=($destination_file)
|
installed_files+=($destination_file)
|
||||||
if [[ $update_run == true ]] ; then
|
if [[ $update_run == true ]] ; then
|
||||||
boxline "$scriptname: added file ${destination_file} to list"
|
run boxline "$scriptname: added file ${destination_file} to list"
|
||||||
else
|
else
|
||||||
if [[ $dry_run == true ]] ; then
|
run mkdir -p "$(dirname "$destination_file")"
|
||||||
# Create the destination directory if it doesn't exist
|
run cp -p ${_source}${_filename} $destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
||||||
boxline "DryRun: mkdir -p $(dirname $destination_file)"
|
run echo "${destination_file}" >> $rundir/installed_files.list
|
||||||
boxline "DryRun: cp -p ${_source}${_filename} $destination_file"
|
|
||||||
else
|
|
||||||
# Create the destination directory if it doesn't exist
|
|
||||||
mkdir -p "$(dirname "$destination_file")"
|
|
||||||
cp -p ${_source}${_filename} $destination_file && boxline "Installed ${_filename}" || warn "Unable to install ${_filename}"
|
|
||||||
fi
|
|
||||||
echo "${destination_file}" >> $rundir/installed_files.list
|
|
||||||
fi
|
fi
|
||||||
done < <(find "$_source" -type f -print0)
|
done < <(find "$_source" -type f -print0)
|
||||||
}
|
}
|
||||||
|
|
||||||
# install-dir(){
|
install-extras(){
|
||||||
# local _source="$1"
|
_extras=()
|
||||||
# local _destination="$2"
|
for file in $(ls ${rundir_absolute}/extras/*.install) ; do
|
||||||
# installed_dirs+=("${_destination}/${_source##*/}")
|
_extras+=("$file")
|
||||||
# if [[ $update_run == true ]] ; then
|
done
|
||||||
# boxline "PRbL updater: added directory ${_destination}/${_source##*/} to list"
|
|
||||||
# else
|
boxborder "Which extras should be installed?"
|
||||||
# if [[ $dry_run == true ]] ; then
|
multiselect result _extras "false"
|
||||||
# boxline "DryRun: cp -r $_source $_destination"
|
|
||||||
# else
|
# For each extra, compare input choice and apply installs
|
||||||
# cp -r $_source $_destination && boxline "Installed ${_source##*/}" || warn "Unable to install ${_source##*/}"
|
idx=0
|
||||||
# fi
|
for extra in "${_extras[@]}"; do
|
||||||
# echo "${_destination}/${_source}" >> $rundir/installed_dirs.list
|
# If the selected user is set to true
|
||||||
# fi
|
if [[ "${result[idx]}" == "true" ]] ; then
|
||||||
# }
|
if [[ $dry_run != true ]] ; then
|
||||||
|
bash "$extra -i"
|
||||||
|
else
|
||||||
|
bash "$extra -D"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
extras-menu(){
|
||||||
|
# Download and install any other extras
|
||||||
|
#if [ -d "${rundir_absolute}/extras/" ] ; then
|
||||||
|
boxborder "Extra installs available. Select and install?"
|
||||||
|
extras_menu=(
|
||||||
|
"$(boxline "${green_check} Yes")"
|
||||||
|
"$(boxline "${red_x} No")"
|
||||||
|
)
|
||||||
|
case `select_opt "${extras_menu[@]}"` in
|
||||||
|
0) boxborder "${grn}Installing extras...${dfl}"
|
||||||
|
install-extras
|
||||||
|
;;
|
||||||
|
1) logger "Skipping extras installs" ;;
|
||||||
|
esac
|
||||||
|
#fi
|
||||||
|
}
|
||||||
|
|
||||||
userinstall(){
|
userinstall(){
|
||||||
|
|
||||||
# Create install directory under user's home directory
|
# Create install directory under user's home directory
|
||||||
mkdir -p ${installdir}
|
run mkdir -p ${installdir}
|
||||||
|
|
||||||
# Check if functions already exist, and check if functions are out of date
|
# Check if functions already exist, and check if functions are out of date
|
||||||
if [ -f ${installdir}/functions ] ; then
|
if [ -f ${installdir}/functions ] ; then
|
||||||
# if functions are out of date, remove before installing new version
|
# if functions are out of date, remove before installing new version
|
||||||
local installerfrev=$(cat ${rundir}/functions | grep functionsrev )
|
local installerfrev=$(cat ${rundir}/functions | grep functionsrev )
|
||||||
if [[ $(vercomp ${installerfrev##*=} $installer_functionsrev ) == 2 ]] ; then
|
if [[ $(vercomp ${installerfrev##*=} $installer_functionsrev ) == 2 ]] ; then
|
||||||
rm ${installdir}/functions
|
run rm ${installdir}/functions
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -351,11 +336,7 @@ userinstall(){
|
||||||
install-file ${rundir}/PRbL/functions ${installdir}
|
install-file ${rundir}/PRbL/functions ${installdir}
|
||||||
|
|
||||||
# Copy bashrc scripts to home folder
|
# Copy bashrc scripts to home folder
|
||||||
#cp -r ${rundir}/lib/skel/* $HOME/
|
|
||||||
install-dir ${rundir}/lib/skel/ $HOME
|
install-dir ${rundir}/lib/skel/ $HOME
|
||||||
# for file in $(ls -a -I . -I .. ${rundir}/lib/skel/) ; do
|
|
||||||
# install-dir ${rundir}/lib/skel/$file $HOME
|
|
||||||
# done
|
|
||||||
|
|
||||||
# Check for dependent applications and warn user if any are missing
|
# Check for dependent applications and warn user if any are missing
|
||||||
if ! check-deps ; then
|
if ! check-deps ; then
|
||||||
|
|
@ -377,14 +358,16 @@ userinstall(){
|
||||||
mkdir -p ${HOME}/.vim/colors
|
mkdir -p ${HOME}/.vim/colors
|
||||||
install-file $rundir/lib/vimfiles/crystallite.vim ${HOME}/.vim/colors
|
install-file $rundir/lib/vimfiles/crystallite.vim ${HOME}/.vim/colors
|
||||||
take-backup $HOME/.vimrc
|
take-backup $HOME/.vimrc
|
||||||
install-file $rundir/lib/vimfiles/vimrc.local $HOME/.vimrc
|
cp $rundir/lib/vimfiles/vimrc.local $rundir/lib/vimfiles/.vimrc
|
||||||
|
install-file $rundir/lib/vimfiles/.vimrc $HOME
|
||||||
|
rm $rundir/lib/vimfiles/.vimrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for existing bashrc config, append if missing
|
# Check for existing bashrc config, append if missing
|
||||||
if [[ $(cat ${HOME}/.bashrc | grep -c 'bashrc.d') == 0 ]] ; then
|
if [[ $(cat ${HOME}/.bashrc | grep -c 'bashrc.d') == 0 ]] ; then
|
||||||
take-backup $HOME/.bashrc
|
take-backup $HOME/.bashrc
|
||||||
echo -e "$bashrc_append" >> $HOME/.bashrc && boxborder "bashc.d installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc${dfl}. Check this file for errors"
|
run echo -e "$bashrc_append" >> $HOME/.bashrc && boxborder "bashc.d installed..." || warn "Malformed append on ${lbl}${HOME}/.bashrc${dfl}. Check this file for errors"
|
||||||
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"
|
run 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
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -398,12 +381,7 @@ userinstall(){
|
||||||
#fi
|
#fi
|
||||||
#clear
|
#clear
|
||||||
|
|
||||||
# Download and install any other extras
|
extras-menu
|
||||||
if [ -f "${rundir_absolute}/extras/*.install" ] ; then
|
|
||||||
for file in ${rundir_absolute}/extras/*.install ; do
|
|
||||||
run /bin/bash "${rundir_absolute}/extras/$file"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [[ $dry_run != true ]] ; then
|
if [[ $dry_run != true ]] ; then
|
||||||
boxborder "${grn}Please be sure to run ${lyl}sensors-detect --auto${grn} after installation completes${dfl}"
|
boxborder "${grn}Please be sure to run ${lyl}sensors-detect --auto${grn} after installation completes${dfl}"
|
||||||
fi
|
fi
|
||||||
|
|
@ -411,7 +389,7 @@ userinstall(){
|
||||||
|
|
||||||
globalinstall(){
|
globalinstall(){
|
||||||
# Create global install directory
|
# Create global install directory
|
||||||
mkdir -p ${globalinstalldir}
|
run mkdir -p ${globalinstalldir}
|
||||||
|
|
||||||
# Copy functions
|
# Copy functions
|
||||||
install-file ${rundir}/PRbL/functions ${globalinstalldir}/functions
|
install-file ${rundir}/PRbL/functions ${globalinstalldir}/functions
|
||||||
|
|
@ -420,9 +398,9 @@ globalinstall(){
|
||||||
# Check for dependent applications and offer to install
|
# Check for dependent applications and offer to install
|
||||||
if ! check-deps ; then
|
if ! check-deps ; then
|
||||||
warn "Some of the utilities needed by this script are missing"
|
warn "Some of the utilities needed by this script are missing"
|
||||||
echo -e "Missing utilities:"
|
logger "Missing utilities:"
|
||||||
echo -e "${bins_missing[@]}"
|
logger "${bins_missing[@]}"
|
||||||
echo -e "Would you like to install them? (this will require root password)"
|
logger "Would you like to install them? (this will require root password)"
|
||||||
utilsmissing_menu=(
|
utilsmissing_menu=(
|
||||||
"$(boxline "${green_check} Yes")"
|
"$(boxline "${green_check} Yes")"
|
||||||
"$(boxline "${red_x} No")"
|
"$(boxline "${red_x} No")"
|
||||||
|
|
@ -451,12 +429,12 @@ globalinstall(){
|
||||||
# done
|
# done
|
||||||
if [[ $(cat /home/${selecteduser}/.bashrc | grep -c prbl) == 0 ]] ; then
|
if [[ $(cat /home/${selecteduser}/.bashrc | grep -c prbl) == 0 ]] ; then
|
||||||
take-backup /home/${selecteduser}/.bashrc
|
take-backup /home/${selecteduser}/.bashrc
|
||||||
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"
|
run 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
|
fi
|
||||||
chown -R ${selecteduser}:${selecteduser} /home/${selecteduser}
|
run sudo chown -R ${selecteduser}:${selecteduser} ${installdir}
|
||||||
if [[ "$bins_missing" == "false" ]] ; then
|
if [[ "$bins_missing" == "false" ]] ; then
|
||||||
boxborder "Checking ${selecteduser}'s bashrc..."
|
boxborder "Checking ${selecteduser}'s bashrc..."
|
||||||
su ${selecteduser} -c /home/${selecteduser}.bashrc.d/11-quickinfo.bashrc
|
run su ${selecteduser} -c /home/${selecteduser}.bashrc.d/11-quickinfo.bashrc
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -468,19 +446,14 @@ globalinstall(){
|
||||||
install-file $rundir/lib/vimfiles/vimrc.local /etc/vim/vimrc.local
|
install-file $rundir/lib/vimfiles/vimrc.local /etc/vim/vimrc.local
|
||||||
fi
|
fi
|
||||||
if [ ! -z $(which sensors-detect) ] ; then
|
if [ ! -z $(which sensors-detect) ] ; then
|
||||||
sensors-detect --auto
|
run sensors-detect --auto
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download and install any other extras
|
# Download and install any other extras
|
||||||
if [ -f "${rundir_absolute}/extras/*.install" ] ; then
|
extras-menu
|
||||||
for file in ${rundir_absolute}/extras/*.install ; do
|
|
||||||
run /bin/bash "${rundir_absolute}/extras/$file"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
#clear
|
#clear
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
remove(){
|
remove(){
|
||||||
if [ -f $rundir/installed_files.list ] ; then
|
if [ -f $rundir/installed_files.list ] ; then
|
||||||
_installed_list=($(cat $rundir/installed_files.list))
|
_installed_list=($(cat $rundir/installed_files.list))
|
||||||
|
|
@ -520,10 +493,11 @@ remove-arbitrary(){
|
||||||
|
|
||||||
update(){
|
update(){
|
||||||
remove-arbitrary
|
remove-arbitrary
|
||||||
git stash -m "$pretty_date stashing changes before update to latest"
|
run git stash -m "$pretty_date stashing changes before update to latest"
|
||||||
git fetch && git pull --recurse-submodules
|
run git fetch && run git pull --recurse-submodules
|
||||||
pushd PRbL
|
pushd PRbL
|
||||||
git pull
|
run git checkout master
|
||||||
|
run git pull
|
||||||
popd
|
popd
|
||||||
install
|
install
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +533,7 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
-D | --dry-run)
|
-D | --dry-run)
|
||||||
export dry_run=true
|
export dry_run=true
|
||||||
box-light
|
box-double
|
||||||
boxtop
|
boxtop
|
||||||
install
|
install
|
||||||
boxbottom
|
boxbottom
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ set mouse-=a
|
||||||
|
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
" show existing tab with 2 spaces width
|
" show existing tab with 2 spaces width
|
||||||
set tabstop=2
|
" set tabstop=2
|
||||||
" " when indenting with '>', use 2 spaces width
|
" " " when indenting with '>', use 2 spaces width
|
||||||
set shiftwidth=2
|
" set shiftwidth=2
|
||||||
" " On pressing tab, insert 2 spaces
|
" " " On pressing tab, insert 2 spaces
|
||||||
set expandtab
|
" set expandtab
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue