From f3b0f9dfe2b6b22eee4db4cc92573b41c82ffd5a Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 20 Aug 2022 01:21:22 +0900 Subject: [PATCH] create homebrew addon --- README.md | 2 +- homebrew/install | 18 ++++++++++++++++++ install | 2 -- mod.bash | 10 ---------- 4 files changed, 19 insertions(+), 13 deletions(-) create mode 100755 homebrew/install diff --git a/README.md b/README.md index 3fa0481..76b0ef4 100644 --- a/README.md +++ b/README.md @@ -13,5 +13,5 @@ sudo ./install or ```sh -sudo ./install desktop +sudo ./install homebrew desktop ``` diff --git a/homebrew/install b/homebrew/install new file mode 100755 index 0000000..55b4fc8 --- /dev/null +++ b/homebrew/install @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail +cd -- "$(dirname -- "$0")" + +function install_homebrew_packages() { + local uid + uid=${SUDO_UID:-$(id -u)} + sudo --user="#$uid" \ + mkdir -p /home/linuxbrew/.linuxbrew + sudo --user="#$uid" \ + NONINTERACTIVE=1 \ + bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + sudo --user="#$uid" \ + /home/linuxbrew/.linuxbrew/bin/brew bundle --global +} + +[[ $(uname -sm) =~ ^(Linux x86_64)$ ]] \ + && install_homebrew_packages diff --git a/install b/install index 852aff0..a392588 100755 --- a/install +++ b/install @@ -5,8 +5,6 @@ cd -- "$(dirname -- "$0")" if (($(id -u) == 0)); then [[ -f /etc/debian_version ]] \ && install_apt_packages - [[ $(uname -sm) =~ ^(Linux x86_64|Darwin .*)$ ]] \ - && install_homebrew_packages fi install_dotfiles install_addons "$@" diff --git a/mod.bash b/mod.bash index 76c454b..10babd6 100644 --- a/mod.bash +++ b/mod.bash @@ -27,16 +27,6 @@ function install_apt_packages() { rsync -rv etc/apt/sources.list.d/ "$apt_sources_dir" } -function install_homebrew_packages() { - local uid - uid=${SUDO_UID:-$(id -u)} - sudo --user="#$uid" \ - NONINTERACTIVE=1 \ - bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" - sudo --user="#$uid" \ - /home/linuxbrew/.linuxbrew/bin/brew bundle --file=.Brewfile -} - function install_addons() { local addon for addon in "$@"; do