Sign inSign up

cmer/do-or-die

By cmer

Updated over 7 years ago

Image
0

1.4K

cmer/do-or-die repository overview

Do Or Die!

Do Or Die (DOD) is a simple program that executes 'checks', and can then execute commands whether the check was successful or not.

For example, it can be used to monitor a host and reboot it remotely if it crashes, or could be used to send an email if a web page changes.

Concepts

  • A configuration file (default: ~/.dod/config.yml) contains parameters for one or multiple checks.
  • Checks are executed one by one at a certain interval, also configured in the configuration file.
  • If the check is successful (returning a zero exit code, or true), a command is optionally run.
  • If the check is unsuccessful (returning a non-zero exit code, or false), a command is optionally run.
  • Check, success or failure commands can be either a Bash script, or pure Ruby code (executed via Kernel.eval).

Configuration File

See config.yml.example for a sample configuration file.

Commands can be either a path to an executable shell script or program (ie: ~/bin/myscript.sh), or pure Ruby code (ie: File.exists?('/tmp/foobar.txt')).

Shell commands are automatically detected if they start with a /, ~, or ., such as: /bin/ls, ~/bin/script or ./foobar.sh.

CLI Parameters

See Help:

./do-or-die --help

Included Helper Methods

Ping

Ping a host.

ping '10.0.0.55'
Shell

Shell out and execute shell commands.

shell 'dig www.google.com'
HTTP_OK?

Checks if a given URL returns 200.

http_ok? 'http://www.mywebsite.com'
Other

For your convenience, DoD included the tplink_smarthome_api Ruby Gem.

Deployment

The easiest way to deploy DOD is to use the Docker image.

Requirements

Tag summary

Content type

Image

Digest

Size

51.6 MB

Last updated

over 7 years ago

docker pull cmer/do-or-die