refactor argument parsing
This commit is contained in:
parent
34499ac38c
commit
a038dc96be
43
install.sh
43
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
|
||||
case "$cmd" in
|
||||
base)
|
||||
apt_sources
|
||||
|
||||
base_applications
|
||||
|
||||
install_docker
|
||||
|
||||
sudo groupadd docker
|
||||
sudo adduser -aG docker "$USERNAME"
|
||||
install_compose
|
||||
elif [[ $cmd == "docker" ]]; then
|
||||
install_docker
|
||||
elif [[ $cmd == "dotfiles" ]]; then
|
||||
;;
|
||||
dotfiles)
|
||||
get_dotfiles
|
||||
elif [[ $cmd == "go" ]]; then
|
||||
install_golang
|
||||
elif [[ $cmd == "goprojects" ]]; then
|
||||
get_public_go_projects
|
||||
elif [[ $cmd == "server" ]]; then
|
||||
;;
|
||||
server)
|
||||
install_server_base
|
||||
elif [[ $cmd == "desktop" ]]; then
|
||||
;;
|
||||
desktop)
|
||||
install_i3
|
||||
if [ -f "./get_private_stuff.sh" ]; then
|
||||
source get_private_stuff.sh
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
update-docker)
|
||||
# install_docker
|
||||
install_compose
|
||||
;;
|
||||
go)
|
||||
install_golang
|
||||
get_public_go_projects
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
Loading…
Reference in New Issue