refactored file install algorithm
This commit is contained in:
parent
896e09f4c5
commit
8439abd6dd
1 changed files with 48 additions and 6 deletions
54
install.sh
54
install.sh
|
|
@ -37,6 +37,7 @@ globalinstalldir="/usr/share/prbl"
|
||||||
bins_missing=()
|
bins_missing=()
|
||||||
backupFiles=()
|
backupFiles=()
|
||||||
installed_files=()
|
installed_files=()
|
||||||
|
installed_dirs=()
|
||||||
|
|
||||||
# List of dependency packaged to be istalled via apt (For Debian/Ubuntu)
|
# List of dependency packaged to be istalled via apt (For Debian/Ubuntu)
|
||||||
packages=(git
|
packages=(git
|
||||||
|
|
@ -125,7 +126,7 @@ usage(){
|
||||||
|
|
||||||
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}')
|
||||||
else
|
else
|
||||||
viminstall=null
|
viminstall=null
|
||||||
|
|
@ -224,14 +225,51 @@ install-file(){
|
||||||
boxline "PRbL updater: added file ${_destination}/${_source##*/} to list"
|
boxline "PRbL updater: added file ${_destination}/${_source##*/} to list"
|
||||||
else
|
else
|
||||||
if [[ $dry_run == true ]] ; then
|
if [[ $dry_run == true ]] ; then
|
||||||
boxline "DryRun: cp -r $_source $_destination"
|
boxline "DryRun: cp $_source $_destination"
|
||||||
else
|
else
|
||||||
cp -r $_source $_destination && boxline "Installed ${_source##*/}" || warn "Unable to install ${_source##*/}"
|
cp $_source $_destination && boxline "Installed ${_source##*/}" || warn "Unable to install ${_source##*/}"
|
||||||
fi
|
fi
|
||||||
echo "${_destination}/${_source##*/}" >> $rundir/installed_files.list
|
echo "${_destination}/${_source##*/}" >> $rundir/installed_files.list
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install-dir() {
|
||||||
|
local _source="$1"
|
||||||
|
local _destination="$2"
|
||||||
|
installed_dirs+=$_source
|
||||||
|
echo "$_destination" >> $rundir/installed_dirs.list
|
||||||
|
# Install the current directory
|
||||||
|
if [[ $update_run == true ]] ; then
|
||||||
|
boxline "PRbL updater: added directory ${_destination}/${_source##*/} to list"
|
||||||
|
else
|
||||||
|
# Loop through subdirectories
|
||||||
|
for item in "$_source"/*; do
|
||||||
|
if [[ -d "$item" ]]; then
|
||||||
|
# If item is a directory, recursively install it
|
||||||
|
install-dir "$item" "$_destination"
|
||||||
|
else
|
||||||
|
install-file "$item" "$_destination"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# install-dir(){
|
||||||
|
# local _source="$1"
|
||||||
|
# local _destination="$2"
|
||||||
|
# installed_dirs+=("${_destination}/${_source##*/}")
|
||||||
|
# if [[ $update_run == true ]] ; then
|
||||||
|
# boxline "PRbL updater: added directory ${_destination}/${_source##*/} to list"
|
||||||
|
# else
|
||||||
|
# if [[ $dry_run == true ]] ; then
|
||||||
|
# boxline "DryRun: cp -r $_source $_destination"
|
||||||
|
# else
|
||||||
|
# cp -r $_source $_destination && boxline "Installed ${_source##*/}" || warn "Unable to install ${_source##*/}"
|
||||||
|
# fi
|
||||||
|
# echo "${_destination}/${_source}" >> $rundir/installed_dirs.list
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
|
||||||
userinstall(){
|
userinstall(){
|
||||||
|
|
||||||
# Create install directory under user's home directory
|
# Create install directory under user's home directory
|
||||||
|
|
@ -339,8 +377,12 @@ globalinstall(){
|
||||||
# If the selected user is set to true
|
# If the selected user is set to true
|
||||||
if [[ "${result[idx]}" == "true" ]] ; then
|
if [[ "${result[idx]}" == "true" ]] ; then
|
||||||
#cp -r ${rundir}/lib/skel/* /etc/skel/
|
#cp -r ${rundir}/lib/skel/* /etc/skel/
|
||||||
for file in `find ${rundir}/lib/skel/ -print` ; do
|
for file in `find ${rundir}/lib/skel/ -print | tail -n +2` ; do
|
||||||
install-file $file /home/${selecteduser}
|
if [[ -d "$file" ]] ; then
|
||||||
|
install-dir $file /home/${selecteduser}
|
||||||
|
else
|
||||||
|
install-file $file /home/${selecteduser}
|
||||||
|
fi
|
||||||
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
|
||||||
|
|
@ -405,7 +447,7 @@ remove-arbitrary(){
|
||||||
userinstall
|
userinstall
|
||||||
globalinstall
|
globalinstall
|
||||||
update_run=
|
update_run=
|
||||||
backup_files=()
|
#backup_files=()
|
||||||
remove
|
remove
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue