diff --git a/README.md b/README.md index 8fcdf9a..0ffd76f 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,6 @@ Bootstrap an OS instance with bare essentials. ## Usage -To bootstrap a macOS instance: - -```bash -curl -O https://git.infektor.net/config/bootstrap/raw/main/bootstrap-macOS.sh && chmod +x bootstrap-macOS.sh && ./bootstrap-macOS.sh -``` - To bootstrap a Linux instance choose one of: ```bash @@ -25,3 +19,9 @@ To bootstrap a Windows instance: ```powershell Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-WebRequest -Uri "https://git.infektor.net/config/bootstrap/raw/main/bootstrap-Windows.ps1" -OutFile "./bootstrap-Windows.ps1"; ./bootstrap-Windows.ps1 ``` + +To bootstrap a macOS instance: + +```bash +curl -O https://git.infektor.net/config/bootstrap/raw/main/bootstrap-macOS.sh && chmod +x bootstrap-macOS.sh && ./bootstrap-macOS.sh +``` diff --git a/bootstrap-macOS.sh b/bootstrap-macOS.sh index cb63d30..f888752 100755 --- a/bootstrap-macOS.sh +++ b/bootstrap-macOS.sh @@ -11,16 +11,13 @@ show_help() { echo echo "Bootstrap a macOS instance with:" echo - echo "* Xcode command line developer tools" - echo "* Homebrew - package manager" - echo "* python - from Homebrew" - echo "* virtualenv - from pip" - echo "* SSH key - from ssh-keygen" - echo "* GitHub public key - with SSH key" - echo "* GitLab public key - with SSH key" - echo "* BitBucket Cloud public key - with SSH key" - echo "* Gogs Cloud public key - with SSH key" - echo "* conduit - configuration manager" + echo "* Install xcode command line developer tools" + echo "* Install homebrew" + echo "* Update packages" + echo "* Install python, pip" + echo "* Install ansible" + echo "* Clone configuration repository" + echo "* Install 1password" echo echo "If any already exist they will not be reinstalled." echo @@ -56,14 +53,6 @@ agree() { esac } -brew_install() { - brew install $1 > /dev/null -} - -pip_install() { - pip install --user $1 > /dev/null -} - export PATH=~/.local/bin:$PATH export PYTHONUSERBASE=~/.local @@ -71,40 +60,23 @@ if ! xcode-select --print-path &> /dev/null; then agree "Install Xcode command line developer tools" && xcode-select --install fi -missing brew && agree "Intalll Homebrew" && /usr/bin/ruby -e \ +missing brew && agree "Install homebrew" && /usr/bin/ruby -e \ "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -agree "Update Homebrew packages" && brew update > /dev/null +agree "Update homebrew packages" && brew update +brew install python -if missing /usr/local/bin/python2 && agree "Install Homebrew python"; then - brew_install python - export PATH=/usr/local/opt/python/libexec/bin:$PATH - echo "To use Homebrew python update your PATH:" - echo 'export PATH=/usr/local/opt/python/libexec/bin:$PATH' +# TODO: Update PATH for pip? + +echo "Install ansible" +pip install --user --break-system-packages ansible jmespath + +if [ ! -d ~/.config/local ]; then + echo "Clone configuration repository" + git clone https://git.infektor.net/config/local.git ~/.config/local fi -missing virtualenv && agree "Install virtualenv" && pip_install virtualenv - -if [ ! -f ~/.ssh/id_rsa ] && agree "Generate SSH key"; then - read -rp "SSH email: " email - [ ! -d ~/.ssh ] && mkdir -p ~/.ssh - ssh-keygen -t rsa -b 4096 -C "$email" -N "" -f ~/.ssh/id_rsa -fi - -if ! missing virtualenv && agree "Set SSH keys on remote Git servers"; then - env=$(mktemp -d) - virtualenv $env &> /dev/null - source $env/bin/activate - pip install git+https://code.infektor.net/config/bootstrap.git > /dev/null - python -c 'import bootstrap; bootstrap.set_ssh_keys()' - deactivate - rm -r $env -fi - -! missing pip && missing conduit && agree "Install conduit" && \ - pip_install git+ssh://git@github.com/kbenzie/conduit.git - -echo "To use installed pip packages update your PATH and PYTHONUSERBASE:" -echo 'export PATH=~/.local/bin:$PATH && export PYTHONUSERBASE=~/.local' +agree "Install 1password" && \ + ~/.local/bin/ansible-playbook ~/.config/local/playbooks/1password.yaml [ -f $0 ] && agree "Remove $0" "N" && rm $0 || exit 0