Based on a true story
Go to file
Fazendaaa f932ff53a6 Changing README to add Docker description, adding Makefile to build the images, adding buildx support and changing Node implementation to work using more environment values. 2020-10-12 13:10:55 -03:00
CSharp Added Hangover.cs and implementation 2016-08-27 17:11:36 +06:00
Dockerfiles Changing README to add Docker description, adding Makefile to build the images, adding buildx support and changing Node implementation to work using more environment values. 2020-10-12 13:10:55 -03:00
R added hangout.R, improved smack-my-bitch-up.R 2016-01-22 05:11:13 +09:00
clojure Clojure implementation (#174) 2019-04-23 13:16:28 +04:00
coffee Removed parenthesis 2015-11-30 11:13:27 +01:00
go ported fucking-coffee script to golang (#163) 2020-01-08 15:19:57 +02:00
groovy Added a groovy version of fucking_coffee 2015-12-07 13:11:33 +02:00
java code cleanup 2020-04-14 17:34:57 +02:00
kotlin 🌟 Added kotlin 2019-04-29 18:51:33 +05:30
nodejs Changing README to add Docker description, adding Makefile to build the images, adding buildx support and changing Node implementation to work using more environment values. 2020-10-12 13:10:55 -03:00
perl Update kumar-asshole.pl 2015-11-29 04:04:28 +01:00
php Created "smack_my_bitch_up" in php 2015-12-10 08:31:16 -05:00
powershell Update fucking_coffee.psm1 2016-03-31 18:41:37 +01:00
python Fixed Delay Typo's in fucking_coffee.py (#187) 2020-02-23 22:15:21 +04:00
python3 Fixed Delay Typo's in fucking_coffee.py (#187) 2020-02-23 22:15:21 +04:00
scala Run script from bash 2015-12-07 14:54:43 +03:30
.env.example initial commit 2015-11-21 23:04:28 +04:00
README.md Changing README to add Docker description, adding Makefile to build the images, adding buildx support and changing Node implementation to work using more environment values. 2020-10-12 13:10:55 -03:00
README.zh-CN.md Update README.zh-CN.md 2020-08-20 15:57:58 +08:00
fucking-coffee.sh add remaining scripts 2015-11-22 20:40:29 +04:00
fucking_coffee.rb Update cron job to be executed on weekdays only 2015-11-26 19:26:15 -06:00
hangover.rb Update cron job to be executed on weekdays only 2015-11-26 19:26:15 -06:00
hangover.sh Update cron job to be executed on weekdays only 2015-11-26 19:26:15 -06:00
kumar-asshole.sh add remaining scripts 2015-11-22 20:40:29 +04:00
kumar_asshole.rb fixed issue with gmail, kumars_email variable scope 2015-11-28 11:30:38 +05:30
smack-my-bitch-up.sh Update cron job to be executed on weekdays only 2015-11-26 19:26:15 -06:00
smack_my_bitch_up.rb Merge pull request #50 from Goldenson/patch-2 2015-11-27 16:07:15 +04:00

English | 简体中文

Hacker Scripts

Based on a true story:

xxx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown... If something - anything - requires more than 90 seconds of his time, he writes a script to automate that.

xxx: So we're sitting here, looking through his, uhm, "legacy"

xxx: You're gonna love this

xxx: smack-my-bitch-up.sh - sends a text message "late at work" to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

xxx: kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

xxx: hangover.sh - another cron-job that is set to specific dates. Sends automated emails like "not feeling well/gonna work from home" etc. Adds a random "reason" from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.

xxx: (and the oscar goes to) fucking-coffee.sh - this one waits exactly 17 seconds (!), then opens a telnet session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has a TCP socket up and running) and sends something like sys brew. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.

xxx: holy sh*t I'm keeping those

Original: http://bash.im/quote/436725 (in Russian)
Pull requests with other implementations (Python, Perl, Shell, etc) are welcome.

Usage

You need these environment variables:

# used in `smack-my-bitch-up` and `hangover` scripts
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

# used in `kumar_asshole` script
GMAIL_USERNAME=admin@example.org
GMAIL_PASSWORD=password

For Ruby scripts you need to install gems: gem install dotenv twilio-ruby gmail

Docker

If you just want to run without having to install any packages, just run the following commands:

docker run -e ... fazenda/hacker-scripts-{PROJECT}

Don't forget to pass the environment variables before with the '-e' in front followed by it, for example:

docker run -e KUMAR_EMAIL="kumar.asshole@example.com" -e GMAIL_USERNAME="" -e GMAIL_PASSWORD="" fazenda/hacker-scripts-kumar-asshole

Each image averages about 30 MB. The values for PROJECT being:

  • fucking-coffe
  • hangover
  • kumar-asshole
  • smack-my-bitch-up

And if you want to make your own build, just run the make command inside the Dockerfiles folder, passing the following arg:

  • REPO_OWNER = yourDockerHubUsername
  • MULTIARCH = true / false -- to build for the following architectures:
    • amd64
    • arm/v6
    • arm/v7
    • arm64/v8
    • ppc64le
    • s390x
  • VERSION = Tag value

Cron jobs

# Runs `smack-my-bitch-up.sh` monday to friday at 9:20 pm.
20 21 * * 1-5 /path/to/scripts/smack-my-bitch-up.sh >> /path/to/smack-my-bitch-up.log 2>&1

# Runs `hangover.sh` monday to friday at 8:45 am.
45 8 * * 1-5 /path/to/scripts/hangover.sh >> /path/to/hangover.log 2>&1

# Runs `kumar-asshole.sh` every 10 minutes.
*/10 * * * * /path/to/scripts/kumar-asshole.sh

# Runs `fucking-coffee.sh` hourly from 9am to 6pm on weekdays.
0 9-18 * * 1-5 /path/to/scripts/fucking-coffee.sh

Code is released under WTFPL.