Skip to content

pinnacol/linecook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

= Linecook

A shell script generator.

== Description

Linecook generates shell scripts using an extensible set of ERB helpers. The
shell scripts and associated resources (files, subscripts, etc) make up
packages that can be used, for example, to provision servers.

Linecook provides a command line tool to manage development servers, generate
scripts, and run scripts on servers. Helpers and recipes can be shared as
gems; the canonical shell helpers are available through
{Linebook}[http://rubygems.org/gems/linebook/].

See the documentation for help to:

* {Setup}[link:files/HowTo/Setup%20Virtual%20Machines.html] and {Control}[link:files/HowTo/Control%20Virtual%20Machines.html] Virtual Machines
* {Generate Scripts}[link:files/HowTo/Generate%20Scripts.html]
* {Run Scripts}[link:files/HowTo/Run%20Scripts.html]

== Usage

Generate a project.

  $ linecook init chalkboard
  $ cd chalkboard

Define default attributes.

  [attributes/chalkboard.rb]
  attrs['chalkboard']['n'] = 3
  attrs['chalkboard']['color'] = 'white'
  attrs['chalkboard']['message'] = 'I will not manually configure my server'

Define a helper.

  [helpers/chalkboard/echo_in_color.erb]
  Echo a string in color.
  (color, str)
    color_codes = Hash[*%W{
      black       0;30   red         0;31
      white       1;37   green       0;32
      light_gray  0;37   blue        0;34
    }]
  --
  echo -e '\033[<%= color_codes[color.to_s] %>m<%= str %>\033[0m'

Use both in a recipe.

  [recipes/chalkboard.rb]
  attributes "chalkboard"
  helpers "chalkboard"
  
  attrs['chalkboard']['n'].times do
    echo_in_color attrs['chalkboard']['color'], attrs['chalkboard']['message']
  end

Define a package to use the recipe; set non-default attributes as needed.

  [packages/chalkboard.yml]
  chalkboard:
    n: 5
    color: blue

Generate the package from the attributes, helpers, and recipe.

  $ linecook build

Check the packages directory to see the resulting script.

  $ cat packages/chalkboard/run
  echo -e '\033[0;34mI will not manually configure my server\033[0m'
  echo -e '\033[0;34mI will not manually configure my server\033[0m'
  echo -e '\033[0;34mI will not manually configure my server\033[0m'
  echo -e '\033[0;34mI will not manually configure my server\033[0m'
  echo -e '\033[0;34mI will not manually configure my server\033[0m'

Now run the package.

  $ linecook run

The package can be run on any server accessible via ssh. See the generated
'config/ssh' file as well as the documentation for {Running Scripts on
Servers}[link:files/HowTo/Run%20Scripts.html].

== Composition

Linecook consists of the following.

  = Components =
  attributes
  helpers
  |-----> recipes -> packages -a-> (scripts) -b-> (servers) <-c- server setup
  files
  templates
  
  = Commands =
  ex: 'linecook build' on the command line
  
  a) env, helper, package, build        # build scripts
  b) run                                # run scripts
  c) start, stop, ssh, snapshot, reset  # server setup/control

Everything to the left of 'scripts' has to do with generating scripts;
everything to the right with running scripts on servers.

== Installation

Linecook is available as a {gem}[http://rubygems.org/gems/linecook].

  $ gem install linecook

== Info 

Developer:: {Simon Chiang}[http://github.com/thinkerbot]
License:: {MIT-Style}[link:files/License_txt.html]

Releases

No releases published

Packages

No packages published