Skip to content

Ever wanted to automate installing loud linux/unix packages or scripts? Now you can.

License

Notifications You must be signed in to change notification settings

alistanis/silentinstall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Ever wanted to automate installing loud linux/unix packages or scripts? Now you can.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published