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

View File

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

View File

@ -90,7 +90,7 @@ loopThroughFiles() {
password=$(displayDialogBox --passwordbox "Enter your password" VALUES 3>&1 1>&2 2>&3) 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 "" > /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 unset password
} }