Add getter and add new flag

This commit is contained in:
Santiago Lo Coco 2022-01-13 21:14:01 -03:00
parent 742fd23832
commit 2dd559bec1
3 changed files with 14 additions and 16 deletions

View File

@ -12,38 +12,32 @@ EOF
checkParameters() {
local counter=0
while getopts ':hwd' flag; do
if [ $((counter++)) -eq 1 ]; then
usage
exit 1
fi
while getopts ':hwdfp' flag; do
case $flag in
h)
usage
exit 0
;;
w)
checkForDependencies "libnewt"
setDialogBox "whiptail"
;;
d)
checkForDependencies "dialog"
setDialogBox "dialog"
;;
l)
f)
checkForDependencies "libnewt"
setDialogBox "whiptail"
setDebugToFile true
;;
p)
installPackages=true
;;
?)
printf '%s: invalid option - '\''%s'\'\\n "${0##*/}" "$OPTARG"
printf '%s: invalid option -%s\n' "${0##*/}" "$OPTARG"
exit 1
;;
esac
done
if [ $counter -eq 0 ]; then
if [ -z "$(getDialogBox)" ]; then
checkForDependencies "libnewt"
setDialogBox "whiptail"
fi
@ -114,7 +108,7 @@ startRice() {
displayDialogBox --title "CocoRice" --msgbox "Hi! This script will auto install my dotfiles."
getGitconfigData
source scripts/linkFiles.sh
source scripts/install.sh
[ -z $installPackages ] && source scripts/install.sh
displayDialogBox --title "CocoRice" --msgbox "All done! Enjoy..."
}
@ -134,4 +128,4 @@ runScript() {
cd $lastFolder
}
runScript "$@"
runScript "$@"

View File

@ -159,6 +159,10 @@ setDialogBox() {
export dialogBox=${1}
}
getDialogBox() {
echo "$dialogBox"
}
setDebugToFile() {
export debugFlagToFile=${1}
}

View File

@ -90,7 +90,7 @@ loopThroughFiles() {
password=$(displayDialogBox --passwordbox "Enter your password" VALUES 3>&1 1>&2 2>&3)
echo $password | sudo -S bash -c "" > /dev/null 2>&1
echo $password | sudo -S bash -c "$(declare -f runDetachedScript); $(declare -f linkFile); runDetachedScript $dialogBox"
echo $password | sudo -S bash -c "$(declare -f runDetachedScript); $(declare -f linkFile); runDetachedScript getDialogBox"
unset password
}