pushabutton

package module
v0.0.0-...-5876104 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2016 License: MIT Imports: 19 Imported by: 0

README

Pushabutton

Minimal web app to run scripts.

Put anything executable in the buttons dir. It'll show up as a button in the web UI. Then, you can push a button!

Get started

In a shell, run the following:

mkdir smalltasks && cd smalltasks
curl -L -o pushabutton https://github.com/engagespark/pushabutton/releases/download/0.0.2/pushabutton-0.0.2-x86-64-glibc
chmod u+x pushabutton
./pushabutton setup
./pushabutton serve

Now, visit http://localhost:8080/.

For more info, run ./pushabutton --help

Introduction

For example, let's create a “date” button that runs the date command. To do this, we create a link to the executable in the buttons dir:

smalltasks$ cd buttons && ln -s $(which date)

Looking at the web-UI, you immediately get a button that you can click.

Pushabutton automatically renders a button for you

After clicking, the executable is run and you get a log:

Pushabutton shows you what is happening on pushing the button

Remember what command you ran yesterday? No worries, Pushabutton remembers.

Pushabutton remembers your button pushes

Simple Parameters

Oh, and then there's parameters! Let's say you're interested in running the id command from the web, to find the IDs of users:

$ ln -s $(which id)

Now, you need to pass a username. Add a textfile id.parameters:

$ cat id.parameters
username

When clicking the button, you'll get a modal asking for the username:

Pushabutton automatically asks for the username!

More features

  • Add descriptions to parameters
  • Make the user choose a value for a parameter with a drop-down list.
  • Determine the valid choice at runtime (by running a script).

How to configure these, see the examples after running setup.

What it is and what it's not

Pushabutton is about enabling non-techies to use your simple helper scripts, too. You copy the binary, you dump the script in the buttons dir, you run the webserver. Then you paste the link in the mail to your colleague, and that's it — done. You can do simple parameters, you have a simple log — but that's it. Pushabutton fills a gap at the low-effort, simple-need end of the spectrum.

It will not be enough for many use cases, and in fact it is not meant to be. Pushabutton does not care about:

  • Authorization (this user can do this, the other one cannot)
  • Scheduling (at 5pm tomorrow do this and at every 2nd Sunday do that)
  • Editing from the web
  • Pipelining
  • Conditional logic
  • Branding and themes

If you need any of those, then Pushabutton is not for you. There are other tools where you can run something from a web-UI, and that do those things well:

Setup & Running & Uninstalling

Run the setup command:

$ ./pushabutton setup

This will setup the necessary directories and some demo scripts:

$ tree
.
├── buttons
│   ├── what_is_the_current_date.sh
│   ├── write-message-to-logged-in-user.sh
│   ├── write-message-to-logged-in-user.sh.parameters
│   └── write-message-to-logged-in-user.sh.parameters.user-tty.choices.sh
├── logs
└── pushabutton

What did we get?

  • buttons is where your scripts live. Link them or drop them there — as long as it's executable, Pushabutton will make a button out of it. At the beginning, two scripts demonstrate how to create your own buttons.
  • logs that's where, for every button push, log files are stored. The journal.log is the file that indexes the rest.

Run the server:

$ ./pushabutton serve Running server on :8080

Want to uninstall? Simple. Just delete the entire directory. There's nothing else.

License

MIT, see LICENSE file

Dependencies, their license & thanks!

We're using the following libraries directly:

gouuid and kingpin.v2

Thru the vendor directory, we're redistributing source code of the following projects:

$ govend -tv

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableButtonIds

func AvailableButtonIds() []string

func FileExists

func FileExists(path string) bool

func Setup

func Setup()

func StartServerOrCrash

func StartServerOrCrash(addr string, baseUrl string)

Types

type Button

type Button struct {
	Id         string
	Title      string
	Parameters []ParameterDef
}

func AvailableButtons

func AvailableButtons() []Button

type GetButtons

type GetButtons struct{}

func (GetButtons) ServeHTTP

func (handler GetButtons) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetLogs

type GetLogs struct{}

func (GetLogs) ServeHTTP

func (handler GetLogs) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LogEntry

type LogEntry struct {
	LogSummaryEntry
	Stdouterr string
}

type LogSummaryEntry

type LogSummaryEntry struct {
	PushId      string
	ButtonId    string
	Timestamp   string
	DateTimeUTC string
	Title       string
	Cmd         string
}

func AvailableLogs

func AvailableLogs() ([]LogSummaryEntry, error)

type ParameterDef

type ParameterDef struct {
	Name        string
	Title       string
	Type        string
	Description string
	Details     map[string]interface{}
}

type PostPush

type PostPush struct{}

func (PostPush) ServeHTTP

func (handler PostPush) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServeAsset

type ServeAsset struct{}

func (ServeAsset) ServeHTTP

func (handler ServeAsset) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServeIndex

type ServeIndex struct {
	// contains filtered or unexported fields
}

func (ServeIndex) ServeHTTP

func (handler ServeIndex) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServeLog

type ServeLog struct {
	// contains filtered or unexported fields
}

func (ServeLog) ServeHTTP

func (handler ServeLog) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServeLogIndex

type ServeLogIndex struct {
	// contains filtered or unexported fields
}

func (ServeLogIndex) ServeHTTP

func (handler ServeLogIndex) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL