diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index b3ae88d..2314669 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -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 "$@" \ No newline at end of file diff --git a/scripts/common.sh b/scripts/common.sh index 54b8659..2ab7936 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -159,6 +159,10 @@ setDialogBox() { export dialogBox=${1} } +getDialogBox() { + echo "$dialogBox" +} + setDebugToFile() { export debugFlagToFile=${1} } diff --git a/scripts/linkFiles.sh b/scripts/linkFiles.sh index 276d4f4..c221fbf 100755 --- a/scripts/linkFiles.sh +++ b/scripts/linkFiles.sh @@ -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 }