• Stars
    star
    205
  • Rank 184,836 (Top 4 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created about 4 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

sysadmin/scripting utilities, distributed as a single binary

Go Report Card license Release

SysBox

This repository is the spiritual successor to my previous sysadmin-utils repository

The idea here is to collect simple utilities and package them as a single binary, written in go, in a similar fashion to the busybox utility.

Installation

Installation upon a system which already contains a go-compiler should be as simple as:

$ go install github.com/skx/sysbox@latest

If you've cloned this repository then the following will suffice:

$ go build .
$ go install .

Finally may find binary releases for various systems upon our download page.

Bash Completion

The subcommand library this application uses has integrated support for the generation of a completion script for the bash shell.

To enable this add the following to your bash configuration-file:

source <(sysbox bash-completion)

Overview

This application is built, and distributed, as a single-binary named sysbox, which implements a number of sub-commands.

You can either run the tools individually, taking advantage of the bash completion support to complete the subcommands and their arguments:

$ sysbox foo ..
$ sysbox bar ..

Or you can create symlinks to allow specific tool to be executed without the need to specify a subcommand:

$ ln -s $(which sysbox) /usr/local/bin/calc
$ /usr/local/bin/calc '3 * 3'
9

Tools

The tools in this repository started out as being simple ports of the tools in my previous repository, however I've now started to expand them and fold in things I've used/created in the past.

You can view a summary of the available subcommands via:

$ sysbox help

More complete help for each command should be available like so:

$ sysbox help sub-command

Examples are included where useful.

calc

A simple calculator, which understands floating point-operations, unlike expr, and has some simple line-editing facilities built into its REPL-mode.

The calculator supports either execution of sums via via the command-line, or as an interactive REPL environment:

$ sysbox calc 3.1 + 2.7
5.8

$ sysbox calc
calc> let a = 1/3
0.333333
calc> result * 9
3
calc> result * 9
27
calc> exit
$

Here you see the magic variable result is always updated to store the value of the previous calculation.

choose-file

This subcommand presents a console-based UI to select a file. The file selected will be displayed upon STDOUT. The list may be filtered via an input-field.

Useful for launching videos, emulators, etc:

  • sysbox choose-file -execute="xine -g --no-logo --no-splash -V=40 {}" ~/Videos
    • Choose a file, and execute xine with that filename as one of the arguments.
  • xine $(sysbox choose-file ~/Videos)
    • Use the STDOUT result to launch instead.

The first form is preferred, because if the selection is canceled nothing happens. In the second-case xine would be launched with no argument.

choose-stdin

Almost identical to choose-file, but instead of allowing the user to choose from a filename it allows choosing from the contents read on STDIN. For example you might allow choosing a directory:

$ find ~/Repos -type d | sysbox choose-stdin -execute="firefox {}"

chronic

The chronic command is ideally suited to wrap cronjobs, it runs the command you specify as a child process and hides the output produced unless that process exits with a non-zero exit-code.

comments

This is a simple utility which outputs the comments found in the files named upon the command-line. Supported comments include C-style single-line comments (prefixed with //), C++-style multi-line comments (between /* and */), and shell-style comments prefixed with #.

Used for submitting pull-requests to projects about typos - as discussed here upon my blog.

collapse

This is a simple tool which will read STDIN, and output the content without any extra white-space:

  • Leading/Trailing white-space will be removed from every line.
  • Empty lines will be skipped entirely.

cpp

Something like the C preprocessor, but supporting only the ability to include files, and run commands via #include and #execute respectively:

#include "file/goes/here"
#execute ls -l | wc -l

See also env-template which allows more flexibility in running commands, and including files (or parts of files) via templates.

env-template

Perform expansion of golang text/template files, with support for getting environmental variables, running commands, and reading other files.

You can freely use any of the available golang template facilities, for example please see the sample template here cmd_env_template.tmpl, and the the examples included in the text/template documentation.

As an alternative you can consider the envsubst binary contained in your system's gettext{-base} package.

NOTE: This sub-command also allows file-inclusion, in three different ways:

  • Including files literally.
  • Including lines from a file which match a particular regular expression.
  • Including the region from a file which is bounded by two regular expressions.

See sysbox help env-template for further details, and examples. You'll also see it is possible to execute arbitrary commands and read their output. This facility was inspired by the embedmd utility, and added in #17.

See also cpp for a less flexible alternative which is useful for mere file inclusion and command-execution.

exec-stdin

Read STDIN, and allow running a command for each line. You can refer to the line read either completely, or by fields.

For example:

$ ps -ef | sysbox exec-stdin echo field1:{1} field2:{2} line:{}

See the usage-information for more details (sysbox help exec-stdin), but consider this a simple union of awk, xargs, and GNU parallel (since we can run multiple commands in parallel).

expect

expect allows you to spawn a process, and send input in response to given output read from that process. It can be used to perform simple scripting operations against remote routers, etc.

For examples please consult the output of sysbox help expect, but a simple example would be the following, which uses telnet to connect to a remote host and run a couple of commands. Note that we use \r\n explicitly, due to telnet being in use, and that there is no password-authentication required in this example:

    $ cat script.in
    SPAWN telnet telehack.com
    EXPECT \n\.
    SEND   date\r\n
    EXPECT \n\.
    SEND   quit\r\n

    $ sysbox expect script.in

find

The find sub-command allows finding files/directories that match a given number of regular expressions. Basic usage is:

$ sysbox find foo bar$

By default the names of files are shown, but you can view either files, directories, or both. The starting point will be the current working directory, but -path can be used to change that:

$ sysbox find -path /etc -files=true -directories=true '(i?)magic'
/etc/ImageMagick-6/magic.xml
/etc/magic
/etc/magic.mime
/etc/sane.d/magicolor.conf

fingerd

A trivial finger-server.

html2text

A simple tool for converting from HTML to Text, added when I realized I'd connected to a system over ssh and there were no console viewers installed, (such as lynx, links, or w3m).

httpd

A simple HTTP-server. Allows serving to localhost, or to the local LAN.

http-get

Very much "curl-lite", allows you to fetch the contents of a remote URL. SSL errors, etc, are handled, but only minimal options are supported.

ips

This tool lets you easily retrieve a list of local, or global, IPv4 and IPv6 addresses present upon your local host. This is a little simpler than trying to parse ip -4 addr list, although that is also the common approach.

markdown-toc

This tool creates a simple Markdown table-of-contents, which is useful for the README.md files as used on github.

make-password

This tool generates a single random password each time it is executed, it is designed to be quick and simple to use, rather than endlessly configurable.

peerd

This deamon provides the ability to maintain a local list of available cluster-members, via the JSON file located at /var/tmp/peerd.json.

See the usage-information for more (sysbox help peerd).

run-directory

Run every executable in the given directory, optionally terminate if any command returns a non-zero exit-code.

The exit-code handling is what inspired this addition; the Debian version of run-parts supports this, but the CentOS version does not.

splay

This tool allows sleeping for a random amount of time. This solves the problem when you have a hundred servers all running a task at the same time, triggered by cron, and you don't want to overwhelm a central resource that they each consume.

ssl-expiry

A simple utility to report upon the number of hours, and days, until a given TLS certificate (or any intermediary in the chain) expires.

Ideal for https-servers, but also TLS-protected SMTP hosts, etc.

timeout

Run a command, but kill it after the given number of seconds. The command is executed with a PTY so you can run interactive things such as top, mutt, etc.

todo

A command to look for TODO items which contain dates in the past, the idea being that you can record notes for yourself, along with deadlines, in your code. Later you can see which deadlines have been exceeded.

tree

Trivial command to display the contents of a filesystem, as a nested tree. This is similar to the standard tree command, without the nesting and ASCII graphics.

urls

Extract URLs from the named files, or STDIN. URLs are parsed naively with a simple regular expression and only http and https schemes are recognized.

validate-json

Validate JSON files for correctness and syntax-errors.

validate-xml

Validate XML files for correctness and syntax-errors.

version

Report the version of the binary, when downloaded from our release page.

validate-yaml

Validate YAML files for correctness and syntax-errors.

watch

Execute the same command constantly, with a small delay. Useful to observe a command-completing.

with-lock

Allow running a command with a lock-file to prevent parallel executions.

This is perfect if you fear your cron-jobs will start slowing down and overlapping executions will cause problems.

Future Additions?

Unlike the previous repository I'm much happier to allow submissions of new utilities, or sub-commands, in this repository.

Github Setup

This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via .github/run-tests.sh which is used by the github-action-tester action.

Releases are automated in a similar fashion via .github/build, and the github-action-publish-binaries action.

Steve

More Repositories

1

sysadmin-util

Tools for Linux/Unix sysadmins.
Perl
940
star
2

bookmarks.public

A template for self-hosted bookmarks using HTML & jQuery.
JavaScript
660
star
3

tunneller

Allow internal services, running on localhost, to be accessed over the internet..
Go
457
star
4

simple.vm

Simple virtual machine which interprets bytecode.
C
452
star
5

deployr

A simple golang application to automate the deployment of software releases.
Go
323
star
6

gobasic

A BASIC interpreter written in golang.
Go
311
star
7

go.vm

A simple virtual machine - compiler & interpreter - written in golang
Go
309
star
8

simple-vpn

A simple VPN allowing mesh-like communication between nodes, over websockets
Go
276
star
9

monkey

An interpreted language written in Go
Go
248
star
10

esp8266

Collection of projects for the WeMos Mini D1
C++
162
star
11

kilua

A minimal text-editor with lua scripting.
C++
158
star
12

sos

Simple Object Storage (I wish I could call it Steve's Simple Storage, or S3 ;)
Go
145
star
13

github-action-publish-binaries

Publish binaries when new releases are made.
Shell
134
star
14

evalfilter

A bytecode-based virtual machine to implement scripting/filtering support in your golang project.
Go
110
star
15

rss2email

Convert RSS feeds to emails
Go
104
star
16

e-comments

External comments for static HTML pages, a lightweight self-hosted disqus alternative.
JavaScript
101
star
17

linux-security-modules

A place to store my toy linux-security modules.
C
87
star
18

marionette

Something like puppet, for the localhost only.
Go
84
star
19

kpie

Simple devilspie-like program for window manipulation, with Lua.
C
77
star
20

dhcp.io

Dynamic DNS - Via Redis, Perl, and Amazon Route53.
Perl
69
star
21

foth

Tutorial-style FORTH implementation written in golang
Go
67
star
22

overseer

A golang-based remote protocol tester for testing sites & service availability
Go
62
star
23

templer

A modular extensible static-site-generator written in perl.
Perl
62
star
24

math-compiler

A simple intel/AMD64 assembly-language compiler for mathematical operations
Go
58
star
25

assembler

Basic X86-64 assembler, written in golang
Go
56
star
26

lighthouse-of-doom

A simple text-based adventure game
C
56
star
27

node-reverse-proxy.js

A reverse HTTP-proxy in node.js
JavaScript
53
star
28

webmail

A golang webmail server.
Go
51
star
29

dotfiles

Yet another dotfile-repository
Emacs Lisp
50
star
30

github2mr

Export all your github repositories to a form suitable for 'myrepos' to work with.
Go
46
star
31

puppet-summary

The Puppet Summary is a web interface providing reporting features for Puppet, it replaces the Puppet Dashboard project
Go
45
star
32

org-worklog

A template for maintaining a work-log, via org-mode.
39
star
33

tweaked.io

The code behind http://tweaked.io/
JavaScript
36
star
34

rss2hook

POST to webhook(s) when new feed-items appear.
Go
35
star
35

pam_pwnd

A PAM module to test passwords against previous leaks at haveibeenpwned.com
C
34
star
36

alphavet

A golang linter to detect functions not in alphabetical order
Go
32
star
37

dns-api-go

The code behind https://dns-api.org/
Go
31
star
38

critical

A simple/minimal TCL interpreter, written in golang
Go
31
star
39

markdownshare.com

The code which was previously used at http://markdownshare.com/
Perl
29
star
40

github-action-tester

Run tests when pull-requests are opened, or commits pushed.
Shell
26
star
41

maildir-tools

Golang-based utility which can be used for scripting Maildir things, and also as a basic email client
Go
22
star
42

chronicle2

Chronicle is a simple blog compiler, written in Perl with minimal dependencies.
Perl
20
star
43

purppura

A server for receiving and processing alerts & events.
Go
20
star
44

implant

Simple utility for embedding files/resources inside golang binaries
Go
20
star
45

dns-api.org

The code which was previously used at https://dns-api.org/
Perl
19
star
46

bfcc

BrainFuck Compiler Challenge
Go
18
star
47

ephemeris

A static blog-compiler
Go
15
star
48

markdownshare

The code behind https://markdownshare.com/
Go
15
star
49

z80-examples

Z80 assembly-language programs.
Makefile
15
star
50

yal

Yet another lisp interpreter
Go
14
star
51

aws-utils

A small collection of AWS utilities, packaged as a single standalone binary.
Go
14
star
52

z80retroshield

Arduino library for driving the Z80 retro-shield.
Shell
12
star
53

Device-Osram-Lightify

Interface to the Osram Lightify system
Perl
12
star
54

github-action-build

Build a project, creating artifacts
Shell
12
star
55

webserver-attacks

Identify attacks against webservers via simple rules
Perl
12
star
56

predis

A redis-server written in Perl.
Perl
11
star
57

da-serverspec

ServerSpec.org configuration for the Debian-Administration cluster.
Ruby
10
star
58

docker-api-gateway

Trivial API-gateway for docker, via HAProxy
Go
10
star
59

http2xmpp

HTTP to XMPP (jabber) bridge.
Perl
9
star
60

nanoexec

Trigger commands over a nanomsg queue
C
9
star
61

go-experiments

Repository containing experiments as I learn about golang
Go
9
star
62

labeller

Script label addition/removal for gmail/gsuite email.
Go
8
star
63

golang-metrics

Automatic submission of system metrics to graphite, for golang applications
Go
8
star
64

ms-lite

A collection of plugins for a qpsmtpd-powered virtual-host aware SMTP system.
Perl
8
star
65

remotehttp

Magic wrapper to deny HTTP-requests to to "local" resources.
Go
8
star
66

dashboard

Redis & node.js powered dashboard skeleton
JavaScript
8
star
67

Buffalo-220-NAS

Installing NFS on a Buffalo 220 NAS device
Shell
8
star
68

asql

A toy utility to process Apache log files via SQL.
Perl
7
star
69

DockerFiles

Container for various dockerfiles.
Shell
6
star
70

yawns

Yet another weblog/news site
Perl
6
star
71

cidr_match.js

A simple module to test whether a given IPv4 address is within a particular CIDR range.
JavaScript
6
star
72

pass

password-store distribution, with plugins.
Shell
6
star
73

knownfs

A FUSE-based filesystem that exports ~/.ssh/known_hosts
Go
6
star
74

mpd-web

Simple HTTP view of an MPD server
Go
6
star
75

mod_writable

Disallow serving writable files under Apache 2.4.x
C
5
star
76

org-diary

Easily maintain a simple work-log / journal with the use of org-mode
Emacs Lisp
5
star
77

mod_blacklist

A simple Apache module to blacklist remote hosts.
C
5
star
78

arduino-mega-z80-simplest

The simplest possible project combining an Arduino Mega and a Zilog Z80 processor
C++
4
star
79

turtle

A simple turtle-implementation, using FORTH as a scripting-language
Go
4
star
80

purple

A simplified version of mauvealert
Perl
3
star
81

subcommands

Easy subcommand handling for a golang based command-line application
Go
3
star
82

thyme

A simple package-building system, using docker
Perl
2
star
83

httpd

Simple golang HTTP server
Go
2
star
84

edinburgh.io

Open pub database
JavaScript
2
star
85

run-directory

A simple application inspired by `run-parts`.
Go
2
star
86

Redis--SQLite

Redis-Compatible module which writes to SQLite
Perl
2
star
87

runme

A quick hack for running commands from README.md files
Go
2
star
88

devopswithdocker.com

Repository created for the Helsinki University course.
Dockerfile
2
star
89

aws-list

Export a dump of all running EC2 instances, along with AMI details, AMI age, etc, etc.
1
star
90

calibre-plugins

A small collection of calibre-plugins.
Python
1
star
91

WebService--Amazon--Route53--Caching

Perl module to cache the results of WebService::Amazon::Route53
Perl
1
star
92

lexing-parsing-linting-stuffs

Code to go with my talk
Python
1
star
93

Test--RemoteServer

The Perl module Test::RemoteServer
Perl
1
star
94

org-tag-cloud

Easily maintain a tag-cloud of org-mode tags.
Emacs Lisp
1
star
95

headerfile

Parse files with simple key:value headers, easily.
Go
1
star
96

z80-cpm-scripting-interpreter

A trivial I/O language, with repl, written in z80 assembler to run under CP/M.
Makefile
1
star