Git Product home page Git Product logo

silentinstall's Introduction

silentinstall

Expect - but simpler! Linux Expect Man Page

Ever wanted to automate installing loud linux/unix packages or scripts easily? Now you can. Hell, it might even work for Windows, but I haven't tried. If you'd like to try it with the built in examples, you'll need to change the paths in the example files to something Windows supports. (C:\Path\To\File.json)

SilentInstall is a package that handles running your commands for you, and handles their expected inputs/outputs in a way you define.

Get it

go get -u github.com/alistanis/silentinstall

What is this for? Doesn't everything run in Docker or have an automated install now?

Unfortunately, for many of us, especially at Universities, this isn't the case. There's lots of legacy cruft lying around that's now finding its way into the cloud, and that poses problems for automation. This is an attempt to simplify those types of application installs.

This is really intended to be a supplement for something like Packer

Ok but can't we just bake an image after manually installing it?

Sure you can. But if you ever need to make changes to the base image, you'll probably run into problems.

In the end, if this is useful to you, awesome, and if not, well that's cool too.

Is this a replacement for Expect?

No. It is not a DSL or Scripting language and it is not as fully featured as expect is. It is much simpler, however, and the configuration format is easy to understand.

Config Format

Below, we'll see a basic json structure that accepts a list of SilentCmds as objects. The "cmd" parameter is a string, and the {{.GOPATH}} will be interpreted as an environment variable. This can be done for any variable currently in your environment following the Go Template format. The "io" parameter is a list of "input" and "output" objects. You specify what the input is, what the output should be, and silentinstall handles the rest. In order to specify a newline, just leave an empty string in "output".

    [
      {
        "cmd": "{{.GOPATH}}/src/github.com/alistanis/silentinstall/silent/test_data/multiple_io.sh",
        "expectations": [
          {
            "input": "Hello! Please enter your name!", "output": "Chris"
          },
          {
            "input": "Please enter your age!", "output": "29"
          }
        ]
      }
    ]

Running SilentInstall

    silentinstall -f silent/test_data/multiple_io_example_config.json
    
    [/Users/cmc666/work/polaris/src/github.com/alistanis/silentinstall/silent/test_data/multiple_io.sh]
    2016/12/01 14:52:36 ui.go:231: ui: Hello! Please enter your name!
    
    2016/12/01 14:52:36 ui.go:231: ui: Chris
    2016/12/01 14:52:36 ui.go:231: ui: Please enter your age!
    
    2016/12/01 14:52:36 ui.go:231: ui: 29
    2016/12/01 14:52:36 ui.go:231: ui: SilentInstall has finished successfully!

Usage

    Usage of ./silentinstall:
      -f string
        	The path of the config file
      -file string
        	The path of the config file
      -v	Prints verbose output if true

Running the Tests

All test dependencies are included in the vendor folder. Simply cd to the source directory and run go test -v

    cd $GOPATH/src/github.com/alistanis/silentinstall/silent
    go test -v

Special Thanks

The guys over at SmartyStreets for Goconvey, which I use in all my projects, jtolds for his goroutine local storage package (which I don't use but Goconvey does) https://github.com/jtolds/gls, and Mitchell Hashimoto and the guys at Hashicorp.

silentinstall's People

Watchers

James Cloos avatar copper lee avatar

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.