From 0b02b61caa49990a8e3ab9d9cf14311471f515e6 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Mon, 3 Aug 2020 14:03:36 +0200 Subject: [PATCH] added options --- README.md | 5 ++++ bin/initDesktop | 69 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8659da6..0adbb26 100644 --- a/README.md +++ b/README.md @@ -47,3 +47,8 @@ If you want you can add a remote repository make sure that it's secure if you ma dotf remote add origin @git.domain.tld/dotfiles.git dotf push ``` + +# To initialize my desktop run +```bash +bash <(curl -sL https://git.rre.nu/jonas/dotfiles/raw/branch/master/bin/initDesktop) +``` diff --git a/bin/initDesktop b/bin/initDesktop index abb5670..99ab58b 100755 --- a/bin/initDesktop +++ b/bin/initDesktop @@ -16,8 +16,21 @@ DOTFILES_RENAME_EXISTING_FILES=( set -aeo pipefail +function printHelp(){ + cat << EOF +Usage ${0##*/} [options..] +-h,-?, --help Show help and exit +-f, --firefox configure firefox and install addons +-g, --gnome configure gnome and install extentions +-d, --dotfiles configure dotfiles +-s, --salt run a masterless salt-call +-y, --yes answer 'yes' on all questions +EOF +} + + function asktobreak(){ - if [[ "$INITDESKTOP_YES" == 1 ]];then + if [[ "$ANSWER_YES" == true ]];then printf "\n" return 1 fi @@ -104,9 +117,55 @@ function firefox_addons(){ exec $HOME/bin/install_firefox_addon } -setup_dotfiles -do_salt_call -gnome_key_bindings -firefox_addons +#initialize all options +ALL=true +FIREFOX=false +GNOME=false +SALT=false +DOTFILES=false +ANSWER_YES=false +while :; do + case $1 in + -h|-\?|--help) + printHelp + exit + ;; + -f|--firefox) + FIREFOX=true + ALL=false + ;; + -g|--gnome) + GNOME=true + ALL=false + ;; + -s|--salt) + SALT=true + ALL=false + ;; + -d|--dotfiles) + DOTFILES=true + ALL=false + ;; + -y|--yes) + ANSWER_YES=true + ;; + --) #End of all options + shift + break + ;; + -?*) + printf "'$1' is not a valid option\n" >&2 + exit 1 + ;; + *) #Break out of case, no more options + break + esac + shift +done + +[[ $ALL == true ]] || [[ $DOTFILES == true ]] && setup_dotfiles +[[ $ALL == true ]] || [[ $SALT == true ]] && do_salt_call +[[ $ALL == true ]] || [[ $GNOME == true ]] && gnome_key_bindings +[[ $ALL == true ]] || [[ $FIREFOX == true ]] && firefox_addons printf "\n DONE!!!!!!!\n"