MAC OS

MAC OS 초기 셋업 자동화 쉘 스크립트(Shell Script)

kudl 2020. 12. 31. 22:33

맥 OS 에서는 터미널을 사용하여 앱 설치가 가능며 아래 샘플에서는 맥용 패키지 관리자인 homebrew를 사용하여 필요한 프로그램 설치를 하였다.

사용방법

터미널을 실행 한 후 startup.sh 파일을 생성한다.

touch startup.sh

startup.sh 파일 실행 권한을 변경한다

chmod +x startup.sh

startup.sh 파일 편집기를 열어서 아래 startup.sh 내용을 넣어준다.

vi startup.sh

startup.sh 파일을 실행한다.

sh startup.sh

 

startup.sh

#!/bin/bash

function print_start() {
  echo "=========================================================================================="
  echo "[START] $1"
  echo "=========================================================================================="
}

function print_end() {
  echo "=========================================================================================="
  echo "[END] $1"
  echo "=========================================================================================="
}

function print_line() {
  echo
  echo "------------------------------------------------------------------------------------------"
  echo
}

# ==========================================================================================
# xcode
# ==========================================================================================
print_start "xcode"
xcode-select --install
print_end "xcode"

print_line

# ==========================================================================================
# homebrew
# ==========================================================================================
print_start "homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
print_end "homebrew"

print_line

# ==========================================================================================
# zsh
# ==========================================================================================
print_start "zsh"
brew install zsh
chsh -s $(which zsh)

curl -fsSL "https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh"
cd ~/.oh-my-zsh/plugins

# ==========================================================================================
# zsh install plugins
# ==========================================================================================
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
git clone https://github.com/zsh-users/zsh-autosuggestions.git
echo "source ${(q-)PWD}/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

echo "plugins=(git zsh-syntax-highlighting zsh-autosuggestions)" >> ~/.zshrc
print_end "zsh"

print_line

# ==========================================================================================
# brew packages
# ==========================================================================================
print_start "brew packages"
brew update
brew cask upgrade
brew tap AdoptOpenJDK/openjdk

brewPackages=(
  git
  docker
  docker-compose
  telnet
  mysql-client
  kubectl
)

for i in "${brewPackages[@]}"; do
  echo "Installing brewPackages $i"
  brew install $i
done

brewCasks=(
  adoptopenjdk8
  adoptopenjdk11
  adoptopenjdk
  intellij-idea
  datagrip
  sourcetree
  sublime-text
  karabiner-elements
  iterm2
  google-chrome
)

for i in "${brewCasks[@]}"; do
  echo "Installing brewCasks $i"
  brew install --cask $i
done
print_end "brew packages"

print_line

# ==========================================================================================
# [Other Apps]
# ==========================================================================================
echo "[Other Apps]"
echo "docker-desktop : https://docs.docker.com/docker-for-mac/install/"
echo "magnet"
echo
echo "Complete!!"
echo

Install 항목

  • xcode install
  • homebrew install
    • zsh install
    • brew packages install
      • brewPackages 항목에 필요한 프로그램이 있다면 추가해주면 된다.
      • 추가 되어 있는 목록 : git, docker, docker-compose, telnet, mysql-client, kubectl
    • brew cask install (dmg 설치형 프로그램들 install)
      • brewCasks 항목에 필요한 프로그램이 있다면 추가해주면 된다.
      • 추가되어 있는 목록 : adoptopenjdk8, adoptopenjdk11, adoptopenjdk, intellij-idea, datagrip, sourcetree, sublime-text, karabiner-elements, iterm2, google-chrome
  • Other Apps에는 추가로 설치가 필요한 프로그램 목록에 대해 홈페이지 링크를 넣어 두었다.

 

'MAC OS' 카테고리의 다른 글

Big Sur(빅서) 배터리 퍼센트 설정  (0) 2020.11.18
맥북 초기 설정 팁  (0) 2020.11.06