Giter Club home page Giter Club logo

workstation-setup's Introduction

Workstation Setup

This project automates the process of setting up a new Mac OS X software development machine using simple Bash scripting. It heavily relies on homebrew.

Goals

The primary goal of this project is to give people a simple script they can run to make their Mac OS X machine prepared and standardized for working on software development projects, especially those common at VMware Tanzu Labs.

Why did we do it this way?

  • A bash script is easy for users to edit locally on-the-fly for small temporary tweaks
  • Everything is in one repository
  • The project name is informative
  • It is easy to fork and customize
  • It has limited requirements: git and bash available on macOS by default

Anti-goals

This project does not aim to do everything. Some examples:

  • We don't install everything that your project needs. These scripts should only install generally useful things, and prefer running quickly over being complete.
  • We avoid setting up and maintaining overly-custom configurations. When there is already a tool that will get us something in a conventional manner, such as Oh My Zsh, we prefer to use it instead of doing things ourselves.

Preparation

  • Run the latest version of macOS unless you have a specific reason not to
  • These scripts might work on previous versions, but are maintained with only the latest macOS in mind
  • Install the latest stable version of Command Line Tools for Xcode

Getting this tool

Open up Terminal.app and run the following command:

mkdir -p ~/workspace &&
  cd ~/workspace &&
  git clone https://github.com/pivotal/workstation-setup.git &&
  cd workstation-setup

Note: This might prompt you to install the latest Xcode command line development tools. Please do so if prompted.

Using this tool

Within ~/workspace/workstation-setup, run the following:

./setup.sh [list of optional configurations]

Examples:

# This will only install the default items
./setup.sh 

# This will install the latest Java and Docker
./setup.sh java docker

Warning: this tool might overwrite existing configurations.

Items installed by default

We recommend that you look at setup.sh to see what is automatically installed. You'll see it calls other scripts within scripts/common, so feel free to take a look at those, too. Note that you can edit any of those files to add or remove items specific for your needs, but the goal of this project is to have sane defaults for our target audience.

Opt-In Configurations

Please look in scripts/opt-in/ for optional, opt-in configurations. Some of these are languages and associated frameworks, such as java and golang. Some are supporting infrastructure, such as docker and kubernetes. Others might be specific tools for application platforms, such as cloud-foundry.

To install any of these, add them as arguments to $> setup.sh. Examples:

# Common for Spring Boot development
./setup.sh java spring-boot docker

# Lots of languages
./setup.sh java ruby node golang python c

# Love those platforms!
./setup.sh golang docker kubernetes cloud-foundry terraform concourse

Analytics

The tool will send anonymous user data to our Google Analytics account, so we can see what command line arguments are popular. You can disable this:

# Remove unnecessary languages when running command
SKIP_ANALYTICS=1 ./setup.sh java ruby node golang c docker

This will also disable brew's data collection.

Having problems?

If you're having problems using the setup script, please let us know by opening an issue.

If you see errors from brew, try running brew doctor and include the diagnostic output in your issue submission.

Customizing

If you'd like to customize this project for a project's use:

  • Fork the project
  • Edit the shells scripts to your liking
  • Profit

Frequently Asked Questions and Troubleshooting

Q: Can I rerun setup.sh?

A: Yes, but with a but. While this script is not entirely idempotent, it does use homebrew's cache to skip reinstalling items, and is pretty lenient about ignoring errors when non-homebrew items get mad that they are already installed. There is no guarantee that some configurations won't be overwritten or duplicated.

Q: Should I run this with sudo?

A: No. setup.sh will ask you for your password take care of that for you.

Q: I'm getting permission errors such as the one below:

Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
  sudo chown -R $(whoami) /usr/local/var/homebrew

A: Short answer: run the suggested command or consider the Possible Solution described below.

Longer answer: You might have multiple user profiles on your machine that are using homebrew (such as this tool) resulting in a mix of file and directory ownership under /usr/local/var/homebrew. This should mostly be an issue with installing things, but not using the tools installed by brew. If you switch between profiles and install tools using brew often you might run into this a lot.

Possible Solution: Try this solution from itectec which makes homebrew's directories writable by the staff group, which should be all admin users on your machine.

  1. Note your default umask for later.

     $> umask
     022
  2. Set homebrew's directories to be writable by everyone in the staff group.

    umask 002 # group write permission
    sudo chmod -R g+w /usr/local/* # group writable
    sudo chgrp -R staff /usr/local/* # staff owned
  3. Set your umask back to the default.

     umask 022 # or whatever you noted earlier

Q: How to I get my change into this tool?

A: Submit a PR, especially for things that are outdated or broken. But, we are being vigilant about keeping this tool lean after a history of letting many idiosyncratic changes creep in over the past few years. As stated above, you can edit the files yourself after downloading them and/or fork.

workstation-setup's People

Contributors

0x2615 avatar alexbasson avatar ams340 avatar andrebrowne avatar bthelen avatar cjcjameson avatar dirkjot avatar ericadohring avatar franciscohui avatar joemoore avatar jonnynabors avatar jsampson1 avatar kehrlann avatar markymarkmcdonald avatar mikfreedman avatar nadeemg avatar nattsw avatar nertzy avatar openbl avatar palfvin avatar philoserf avatar pivotal-ash avatar professor avatar rctay avatar smgoller avatar spilth avatar textbook avatar willmadison avatar xinzweb avatar zgagnon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

workstation-setup's Issues

git-pair - git-duet

I wanted to start a conversation about git-pair. I've been using it for 2 years without issue, some devs here think we should continue on with git-pair

I did notice that git-duet does not allow for soloing and does not look at a local repo's .pairs file

git duet ts ts
open /Users/pivotal/.git-authors: no such file or directory

Use `ln -s` instead of `cp`?

Rather than copy configuration files to the destination, why not symlink them? That would allow users of this repo to get config updates with a simple git pull.

Homebrew warnings stop script from running

We had a homebrew warning around not having latest Xcode.

Ensuring you have a healthy Homebrew environment...
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Your Xcode (7.3) is outdated
Please update to Xcode 7.3.1.
Xcode can be updated from the App Store.

The script stops running, even though there are no Xcode updates available for us in the App Store. It would be great to have an option to continue in spite of the warning.

entering password multiple times

Currently, we need to enter the root password multiple times while the script is running. This means that I can not let the script run on its own and come back to it an hour later. I need to monitor the script for password prompts.

I believe that with bash, there is a way to enter it once and for the script to pass it along to the commands it is running.

Ruby 2.3.0

We should install the latest Ruby, which as of now is Ruby 2.3.0

Disable iTerm drag-n-drop behavior

iTerm is customizable in the following behavior:

If you have selected (highlighted) text in the terminal, and then you drag and drop from the selection anywhere else, it pastes it.

The customization, which we'd like to automate and standardize on, is that this feature is that if you hold apple / command while drag and dropping, but not otherwise.

ruby.sh

I was wondering if we would want to do

echo "Adding rbenv initialization to .bash_profile..."
bash-it enable plugin rbenv

instead of

echo "Adding rbenv initialization to .bash_profile..."
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

I noticed this difference in comparing our current default palo alto / san francisco machine with a workstation-setup machine.

Bash-it also loads the auto-completion script
https://github.com/Bash-it/bash-it/blob/master/plugins/available/rbenv.plugin.bash

Some apps are not installing during the setup script

I ran the ./designer.sh command and installed most of the apps except these:

  • macvim
  • adobe creative cloud installer
  • sketch
  • recordit
  • skitch
  • licecap
  • screenflow

For reference, this is the list of successfully installed apps
screen shot 2016-03-14 at 4 58 55 pm

Add vagrant

Seems like many projects would use vagrant. Thoughts?

setting computer name

I noticed that on a machine that I recently brought up, that I had to set the computer name manually.

I know that base MacOS install from netboot asks for a machine name. Perhaps this did not occur on this machine. I was wondering if our script should remind the user to set the machine name?

Another machine I brought up was fine.

sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"

setup fails when 'brew doctor' has any warning

We are using 'set -e' to exit if any process exits with a non-zero status. This is generally good, but 'brew doctor' exists non-zero on any warning. We may want to allow that one to give non-zero status.

I have two people next to me who thought that the script 'crashed' because XCode is out of date (probably due to a lack of knowledge about bash/brew etc). The script should continue on brew doctor warnings.

pivotal_ide_prefs are not affecting intellij

It looks like pivotal_ide_prefs is run, but intellij is not picking them up.

Work around steps
./engineer.sh
start up intellij (select theme, keymaps, etc)
quit intellij
re-run pivotal_ide_prefs
start up intellij

Nothing references teardown.sh

It looks like scripts/teardown.sh will uninstall Homebrew. Should this be documented in the README, or is it not ready for prime-time?

Configuring terminal prompt

I'd love to get help on configuring the iTerm terminal prompt.

Current:
current
Desired:
desired

The first line is a little too verbose. I'd love to turn off the timestamp
The second line should show who is paired.

Script halts when certain apps are already installed

Interestingly, it looks like homebrew is doing its darnedest to work around this problem, but it doesn't seem to be working. We've observed it with RubyMine and ShiftIt while running ./labs-engineer.sh:

==> Downloading https://github.com/fikovnik/ShiftIt/releases/download/version-1.6.3/ShiftIt-1.6.3.zip
Already downloaded: /Users/pivotal/Library/Caches/Homebrew/Cask/shiftit--1.6.3.zip
==> Verifying checksum for Cask shiftit
==> Removing App: '/Applications/ShiftIt.app'
Error: It seems there is already an App at '/Applications/ShiftIt.app'.
Error: nothing to install
# script halts

Script exits early when git-duet is already installed

When git-duet is already installed, workstation-setup attempts to reinstall it. The final step in the process fails and the script exits early:

Installing Git and associated tools
Warning: git-2.9.3 already installed
Warning: git-duet/tap/git-duet-0.3.0 already installed
==> Installing git-pair from pivotal/tap
==> Downloading https://github.com/pivotal/git_scripts/archive/v1.4.0.tar.gz
==> Downloading from https://codeload.github.com/pivotal/git_scripts/tar.gz/v1.4.0
######################################################################## 100.0%
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/git-pair
Target /usr/local/bin/git-pair
already exists. You may want to remove it:
  rm '/usr/local/bin/git-pair'

To force the link and overwrite all conflicting files:
  brew link --overwrite git-pair

To list all files that would be deleted:
  brew link --overwrite --dry-run git-pair

Possible conflicting files are:
/usr/local/bin/git-pair
==> Summary
🍺  /usr/local/Cellar/git-pair/1.4.0: 6 files, 13.8K, built in 0 seconds

Running brew uninstall git-pair && rm '/usr/local/bin/git-pair' solves this issue, but ideally, programs that are already installed should not cause the script to fail.

virtual machine for workstation-setup development

I heard a rumor that VMWare has a product that will run macOS in a virtual machine on apple hardware. If this is the case, then we can improve our cycle time with working on this repo.

We could

  1. install the virtual machine, install 10.11, install XCode, save the image as a starting point.
  2. make changes to the script, test it on the virtual machine
  3. re-create the virtual machine from step 1.

If anyone does this, let's write down the steps. I hope running the script in a virtual machine is not too time-consuming.

Todd

Update readme

Maybe the readme could explain how this is different than sprout-wrap and why we should be using this instead of the normal way we setup machines at Pivotal.

I feel like I'm missing some context

Handling differences between engineering organizations

I'm transitioning from Labs to the Data organization. They have very specific installation needs that the other Labs offices will not need or use.

I'm assuming we'd create a new bash script that runs after engineer.sh, that is unique to each organization? (e.g. cf-engineer.sh, data-engineer.sh)

But where do store that script?
a) in this github repo
b) somewhere else (different github repo, google drive, etc.)

Thoughts?

git commands

While working on workstation-setup project, I'm really missing these git commands / aliases

git co (git checkout)
gst (git status)

I realize that I might be opening a can-of-worms as some pivots have a lot of git tweaks. I feet that my list is pretty common in SF and PA and are used frequently each day.

iTerm look and feel

I prefer the settings in iTerm that are present in sprout-wrap. I'm open for something better, but I find "blue on black" hard to read. An xCode programmer might enjoy it =)

screen shot 2016-02-01 at 3 23 36 pm

screen shot 2016-02-01 at 3 23 56 pm

git clone --depth=1 for bash-it (and others?)

The bash-it download takes much longer than necessary. There might be other places where the speed could be improved with a shallow clone.

I'd fix it right now but I'm working on another project. I'll try to get a PR for this soon.

copy and paste in vim

I'm not a heavy vi user, so I usually don't have many opinions with vi, and I let the vi masters duke it out.

However, I do expect to be able to highlight text with my mouse and copy it into the mac copy-butffer and paste it back into vi.

This is how vi works in macOS, and as a novice vi user, this is how I expect it to work in vim.

Can we fix this version of vim?

Enable ShiftIt in OSX Privacy Settings automatically.

After running ./engineer.sh I was surprised to not be able to use ShiftIt. I needed to:

  • start ShiftIt
  • enable ShiftIt in Preferences > Security & Privacy > Accessibility > Privacy

It would be nice to not need to do these two steps after running the installation script.

Configuring ShiftIt fails in macOS Sierra - sqlite3.OperationalError: attempt to write a readonly database

Configuring ShiftIt
Password:
Traceback (most recent call last):
  File "/usr/local/bin/tccutil", line 294, in <module>
    main()
  File "/usr/local/bin/tccutil", line 281, in main
    insert_client(item)
  File "/usr/local/bin/tccutil", line 212, in insert_client
    c.execute("INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','%s',%s,1,1,NULL,NULL)" % (client, client_type))
sqlite3.OperationalError: attempt to write a readonly database

Are we still generating a setup.log?

The last line of the script echos that we are creating one. I don't see one on the filesystem, and I don't see it referenced in the code.

options

  • bring it back?
  • delete echo?
  • other?

syntax error

./scripts/setup.sh: line 40: syntax error near unexpected token `fi'

It's missing a 'then'

User experience is poor when script exits early

I was running these scripts on my project, and when everything worked it was fantastic.

However, if there is a problem (say, brew doctor returns 1 because of problems with macports or fink), then these scripts print out the entire output from that command, and then return.

It would be really, very, very nice to have a hook at the end of the script that checks to see if it is exiting and prompts the user to fix these things and then continue running the script. Otherwise, it sort of looks like it worked, and the user may not understand why they do not have all the things this project provides.

I even think that there is such a feature in bash - they are called exit traps.

http://redsymbol.net/articles/bash-exit-traps/

Remove dock clutter

  1. dock should auto-hide
  2. dock should only contain Finder, iTerm, Chrome, RubyMine, IntelliJ

Check out sprout-osx-settings::dock_preferences for implementation ideas

CF-CLI broken in brew...

It seems like the command to install the cf cli is broken. It seems like its un-related to the script, as a manual brew install cf-cli does not work either... thoughts?

echo
echo "Installing Cloud Foundry Command-line Interface"
brew tap cloudfoundry/tap
brew install cf-cli

Does not work...

Installing Cloud Foundry Command-line Interface
==> Installing cf-cli from cloudfoundry/tap
==> Downloading https://cli.run.pivotal.io/stable?release=macosx64-binary&version=6.17.0&source=homebrew

curl: (6) Could not resolve host: cli.run.pivotal.io
Error: Failed to download resource "cf-cli"
Download failed: https://cli.run.pivotal.io/stable?release=macosx64-binary&version=6.17.0&source=homebrew

Docker for mac

We'll be putting docker on the Data R&D machines with bash completion.

Is this something we want on labs machines?

git config: push.default is 'matching'

'matching' means all local branches that match an upstream name will be pushed. This is really dangerous. We should change this to 'simple' or 'current' but really, we can probably just unset it and let git decide the default.

Run pivotal ide prefs

How about:

$ git clone https://github.com/pivotal/pivotal_ide_prefs.git
$ pushd pivotal_ide_prefs/cli/
$ ./bin/ide_prefs install --ide=intellij
$ ./bin/ide_prefs install --ide=rubymine
$ popd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.