Friday, 8 March 13 I am Gerhard Lazu, the Lead Engineer for howareyou.com I will be speaking today about Bourne. Jason Bourne is a man of action, He does not have time for hubot or for READMEs, he just... sudo
by Brian Fox in the late 80s, it is the default shell in Linux and Mac OS 10 Bash greatly improves on BourneShell, and picks the best parts from C-Shell and KornShell The name, bash, is a pun on Stephen Bourne, the author of BourneShell
much more than just a command-line interpreter It has loops, conditions, functions & variables It can do background jobs & run sub-shells It even does meta-programming! Yes, it has eval
a key-value store that everybody knows about - but ignores Except Jason Bourne - it’s his key-value store of choice You can set, modify & unset new or pre-defined variables
&& source $HOME/.env Friday, 8 March 13 So, Jason Bourne walks into your office. What is the first thing that he does? He fires up iTerm and inserts this line in your shell’s profile It reads: “if file exists, source it”
3 local _github_token="$(git config --get github.token) 4 5 if [[ -n $_github_user ]] && [[ -n $_github_token ]] 6 then 7 local _github_url="https://raw.github.com/..." 8 source <(curl -fsSL $_github_url) 9 else ... Friday, 8 March 13 The .env file that gets sourced defines and runs a function which in turn sources a remote file from a git repository Lines 2 and 3 read your github user and token, the one set in your global git config Line 5 guards against missing values Lines 7 and 8 load the remote file in your env
redis) 4 5 for _brew_dependency in ${brew_dependencies[@]} 6 do 7 brew install "$_brew_dependency" 8 done Friday, 8 March 13 setup is a bash script Line 1 checks if brew is installed, otherwise stops execution and opens page with instructions Line 3 is a list of your app’s system dependencies Lines 5 to 8 install your app’s system dependencies via brew
bundle install --local 13 14 echo "Godspeed Bourne!" Friday, 8 March 13 You would also check for bundler, then install all vendored gems The --local flag will not pull any gems from remote bundle package is your friend, as is vendor/cache Now that your app is setup, how do you start it? You type boot
bundle exec foreman start -f=Procfile.development 4 else 5 $@ 6 fi Friday, 8 March 13 By default, your app and all its components get started via Foreman (Lines 1 to 3) If you pass in any arguments they will be executed as a standalone command. For example boot rails server would only start the rails server
tag_for_deploy 6 if_assets_changed && compile_assets 7 _deliver Friday, 8 March 13 This is a bourne build script Line 1 stops this script’s execution if any of the commands exit with a non-zero status Lines 3 to 7 are bash functions, the actual code is not relevant, the intentions however are. Notice line 7, I will get back to it.
are running the build script locally, it is likely that you want to deploy to your local VM All you have to do is overwrite the $HOSTS variable By default, successful builds will be pushed to your production instances by Jenkins
pure bash deployment tool deliver has no dependencies It only cares about having enough info in the shell environment to do its job If you want to find out more about deliver, come to my next LRUG talk in March
you can use env more - the key-value store that is everywhere You can make use of the local script or bin man-drawers Do you remember Jason Bourne’s newspaper-fight? You ARE Jason Bourne, bash IS that newspaper!