GithubHelp home page GithubHelp logo

shutitfile's Introduction

ShutItFile

Automation for everyone

A ShutItFile is an extension of the Dockerfile concept for shell automation.

In the same way that Dockerfiles were designed as a simple way to create Docker images, ShutItFiles are a simple way to create ShutIt scripts.

ShutItFiles can be used to automate tasks, or automate the building of composable Docker images.

Here's an annotated example of an bash script which:

  • Logs onto a server
  • Runs a command and waits until it completes
  • pings a server, and takes different actions based on its output
  • Gives you a shell mid-run to do with what you will
  • Logs out
# Specify we are working in a simple bash shell (the default). Other options
# include 'docker' container.
DELIVERY bash

# Log into my server
LOGIN ssh [email protected]
# A password is likely required, so we prompt for one here
GET_PASSWORD Input your password

# Run the command 'whoami'
RUN whoami
# If the output of the previous RUN command is not as we expect (imiell),
# throw an error
ASSERT_OUTPUT imiell

# Ensure a file is removed, sleep for 15 seconds, then create that file
# Run in the background
RUN rm -f /tmp/event_complete && sleep 15 && touch /tmp/event_complete &
# List files in the /tmp directory
RUN ls /tmp
# Wait until the output of the previous command contains the filename created.
# It re-tries every 5 seconds until this is seen.
UNTIL ['.*event_complete.*']

# ping and run different commands based on what happens
SEND ping -c 1 -t 1 bbc.co.uk
EXPECT_REACT ['.*0 packets received.*=echo error > /tmp/bbc_pingres','.*Time to live exceeded.*=echo ttl_exceed > /tmp/bbc_pingres','.*1 packets received.*=echo ok > /tmp/bbc_pingres','.*Unknown host.*=echo unknown > /tmp/bbc_pingres']

# You can debug by creating a 'pause point'. This will give you a shell mid-run
# to examine the state of the system.
PAUSE_POINT You now have a shell to examine the situation

# Exit the session
LOGOUT

Here is a video of the above script being run on my laptop.

asciicast of above script

A cheat sheet for ShutIt commands is available here

Installation

sudo pip install shutit

Examples

See here

shutitfile's People

Contributors

ianmiell 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

Watchers

 avatar  avatar  avatar  avatar  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.