diff --git a/install.sh b/install.sh index b6c1233..796e9d7 100755 --- a/install.sh +++ b/install.sh @@ -29,30 +29,20 @@ HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2" install_dependencies() { fmt_note "installing dependencies ..." - case $(get_os_type) in - "linux" ) - case $(get_linux_dist) in - "ubuntu"|"debian" ) - $SUDO apt-get update - $SUDO apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils - ;; - "alpine" ) - $SUDO apk update - $SUDO apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux - ;; - * ) fmt_error "dfs auto-install is not implemented on linux distribution: $(get_linux_dist)" - esac + case $(get_os_name) in + "ubuntu"|"debian" ) + DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/ubuntu.sh apt-install + ;; + "alpine" ) + DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/alpine.sh apk-add ;; "macos" ) - $SUDO brew update - $SUDO brew install git zsh curl tmux vim util-linux + DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/macos.sh brew-install ;; "msys" ) - pacman -Syu - pacman -S tmux git zsh bash curl vim - SUDO="" + DFS_LITE=$DFS_LITE $SUDO $DOTFILES/tools/msys2.sh pacman-S ;; - * ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_type)" + * ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_name)" esac } diff --git a/tools/alpine.sh b/tools/alpine.sh index 89442a4..59d81c2 100755 --- a/tools/alpine.sh +++ b/tools/alpine.sh @@ -12,9 +12,13 @@ apk_add() { apk update - # mass installation - apk add zsh git tmux vim curl wget bash python3 py3-pip htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils util-linux - #for i in {fzf,ripgrep}; do apk add $i -y; done + # lite + apk add zsh bash git tmux vim curl fzf iputils coreutils util-linux + + # full + if [[ -z "$DFS_LITE" ]]; then + apk add wget python3 py3-pip htop gcc g++ cmake make perl linux-headers bind-tools man-db + fi } set_timezone() diff --git a/tools/common.sh b/tools/common.sh index 4288319..87fcdfa 100755 --- a/tools/common.sh +++ b/tools/common.sh @@ -172,7 +172,8 @@ apost_beacon() post_beacon "$@" 1>/dev/null & } -get_os_type() { +get_os_type() +{ local ans="unknown" case "$(uname -s)" in Darwin*) ans="MacOS";; @@ -184,7 +185,8 @@ get_os_type() { echo $ans | tr '[:upper:]' '[:lower:]' } -get_linux_dist() { +get_linux_dist() +{ local ans="unknown" if [ -f /etc/os-release ]; then . /etc/os-release @@ -206,6 +208,15 @@ get_linux_dist() { echo $ans | tr '[:upper:]' '[:lower:]' } +get_os_name() +{ + local ans=$(get_os_type) + if [[ "$ans" == "linux" ]]; then + ans=$(get_linux_dist) + fi + echo $ans +} + # if bash-ed, else source-d if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then $1 "${@:2}" diff --git a/tools/macos.sh b/tools/macos.sh new file mode 100644 index 0000000..0edd212 --- /dev/null +++ b/tools/macos.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +brew_install() +{ + brew update + brew install git zsh curl tmux vim util-linux +} + +router() +{ + case $1 in + brew_install ) brew_install ;; + * ) echo unknown command "$1". available: brew_install;; + esac +} + +router $@ diff --git a/tools/msys2.sh b/tools/msys2.sh index 48cc70d..00ed05d 100755 --- a/tools/msys2.sh +++ b/tools/msys2.sh @@ -13,7 +13,12 @@ set_mirror() pacman_S() { pacman -Syu - pacman -S tmux git zsh curl vim wget base-devel mingw-w64-x86_64-toolchain make cmake gcc zip unzip python3 python3-pip man-pages-posix + # lite + pacman -S tmux git zsh bash curl vim + # full + if [[ -z "$DFS_LITE" ]]; then + pacman -S wget base-devel mingw-w64-x86_64-toolchain make cmake gcc zip unzip python3 python3-pip man-pages-posix + fi } router() diff --git a/tools/ubuntu.sh b/tools/ubuntu.sh index e6a98cf..ef753e4 100755 --- a/tools/ubuntu.sh +++ b/tools/ubuntu.sh @@ -11,17 +11,15 @@ set_mirror() apt_install() { - # basic packages - apt-get update - for i in {man-db,vim,ca-certificates}; do apt-get install $i -y; done + apt-get update -y # lite - apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils + apt-get install -y git zsh bash tmux vim curl inetutils-ping less bsdmainutils ca-certificates # full if [[ -z "$DFS_LITE" ]]; then apt-get install wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron openssh-client openssh-server htop gcc g++ cmake make zip - for i in {fzf,ripgrep}; do apt-get install -y $i; done + for i in {fzf,ripgrep,man-db}; do apt-get install -y $i; done fi }