From a038dc96be607003648499466d465e2a518b2e33 Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Sat, 2 Jun 2018 17:17:16 +0200 Subject: [PATCH] refactor argument parsing --- install.sh | 63 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/install.sh b/install.sh index ea4d78a..daaed88 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ set -e # install.sh -# This script installs my basic setup for a debian laptop +# This script installs my basic setup for a debian machine USERNAME=fschl @@ -68,7 +68,6 @@ base_applications() { } install_server_base() { - echo "update and installing server base tools..." DEBIAN_FRONTEND=noninteractive @@ -244,7 +243,6 @@ install_golang() { go get golang.org/x/tools/cmd/goimports go get golang.org/x/tools/cmd/gorename - go get github.com/FiloSottile/vendorcheck go get github.com/nsf/gocode #done ) @@ -310,36 +308,39 @@ main() { local cmd=$1 if [[ -z "$cmd" ]]; then - echo "Usage: \n base | desktop | server | dotfiles | compose | go" + echo "Usage: \n base | desktop | server | dotfiles | update-docker | go" fi - # TODO: refactor to case - if [[ $cmd == "compose" ]]; then - install_compose - elif [[ $cmd == "base" ]]; then - apt_sources - - base_applications - - install_docker - - install_compose - elif [[ $cmd == "docker" ]]; then - install_docker - elif [[ $cmd == "dotfiles" ]]; then - get_dotfiles - elif [[ $cmd == "go" ]]; then - install_golang - elif [[ $cmd == "goprojects" ]]; then - get_public_go_projects - elif [[ $cmd == "server" ]]; then - install_server_base - elif [[ $cmd == "desktop" ]]; then - install_i3 - if [ -f "./get_private_stuff.sh" ]; then - source get_private_stuff.sh - fi - fi + case "$cmd" in + base) + apt_sources + base_applications + install_docker + sudo groupadd docker + sudo adduser -aG docker "$USERNAME" + install_compose + ;; + dotfiles) + get_dotfiles + ;; + server) + install_server_base + ;; + desktop) + install_i3 + if [ -f "./get_private_stuff.sh" ]; then + source get_private_stuff.sh + fi + ;; + update-docker) + # install_docker + install_compose + ;; + go) + install_golang + get_public_go_projects + ;; + esac } main "$@"