Published in


A Web Service Written in Pure Bash.

Is it beer o’clock yet?

The Dirt

The service itself is currently running on a Ubuntu 16.10 droplet on DigitalOcean. To expose my service I needed to open a connection with the outside world and initially played with netcat as it’s preinstalled on most *nix machines. This task wasn’t familiar to me at all, but I couldn’t read the incoming request and I couldn’t handle two users connecting at the same time. I explored inetd which lacked of documentation beyond the man page. Continuing with my research I found xinetd which is a more secure version of inetd. I also found a lot more sufficient documentation and user guides on creating a service. After installing xinetd I began building a primitive version of my pure bash service called beeroclock.

xinetd man page

Code Digestion

When a request is made it is consumed, the headers are parsed until we find the a carriage return signaling that we’ve hit the body, and then properly assign each piece to a variable. In this case we only care about GET requests and if pathname is correct. The service responds to two paths and one query parameter.

Bash Performance Test — Regex vs If/Else

To Recap…

Bash should probably remain a scripting language, but like any language we should explore and find ways to bend it until it breaks. I really enjoyed building beeroclock and always enjoy asking my co-workers what time it is. The source code can be found here hhsnopek/beeroclock and I welcome contributions to better the project — Cheers!



Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store