Sunday, July 9, 2017

Bash - exit on failure

The problem

Scripts like the following will execute each step, even if one fails:

 #!/bin/bash
 
 echo "Shutting down mysqld. Please wait."
 
 # following shuts down mysql before stopping the container
 docker exec mysql /usr/bin/mysqladmin shutdown
 
 echo "Stopping the individual containers..."
 
 # stop the containers
 docker stop mysql
 docker stop sphinx
 docker stop apache

The problem with the above is that: if MySQL service does not completely shutdown (i.e., has some sort of error), there is nothing to stop the script from executing the last three steps. Without the database services stop, those will corrupt your database. (I learned this the hard way.)

One solution

The desirable solution is for the script to exit without stopping the Docker services. This can be done by making the MySQL shutdown line look like:

 docker exec mysql /usr/bin/mysqladmin shutdown || \
  { echo 'MySQL shutdown failed' ; exit 1; }

Note: above should all be on a single line (without the "\").

The above gives you a warning that something didn't work right and exits the script before attempting to stop the Docker containers.

Sunday, July 2, 2017

Copy and paste in a terminal

LatestHackingNews has an article about Linux commands, one of which involves using the keyboard to copy and paste. The article indicates that ctrl-c will copy whatever's highlighted to the clipboard. This isn't accurate in that ctrl-c does what you expect it to do (interrupt a running process). The proper key sequence is shift-ctrl-c (paste is shift-ctrl-v).

Saturday, July 1, 2017

What was I reading in June 2017

2017-06-02

- GEF - GDB Enhanced Features documentation
- Practical Guide to Bare Metal C GitBook
- Free software is suffering because coders don't know how to write documentation - It's not limited to free software.
- Pinboard Acquires Delicious - I miss the original verison of Delicious. The later versions, not so much.
- Mobile Sensors Exploitation

2017-06-06

- The Telnet BBS Guide - Ah, memories....
- Krypt.co scores a $1.2M seed round to simplify developer encryption key security

2017-06-08

- Five years of IPv6: whither the next five? APNIC Blog
- The Boolean Satisfiability Problem [SAT] and SAT solvers in 5 mins or more - A bit math-heavy.
- A Brief History of the UUID - I'm of the opinion that the faster you put technology and people on line, the sooner we'll start seeing collisions (not every conforms to standards, even when you make it mandatory).
- How highly advanced hackers ab used satellites to stay under the radar

2017-06-09

- Docker Containers Are Hard Just Like All Great Technologies - Container Journal - I might agree to that statement later. For now, Docker containers are hard because the developers keep modifying features and syntax. Then again, mebbe I'm just annoyed because I've had to rewrite Dockerfiles due to deprecated features.

2017-06-10

- Jupyter Notebooks

2017-06-11

- Visual Cryptography Kit

2017-06-12

- forsyth / plan9-9k Bitbucket - Wife once asked me what I'd do when Linux becomes mainstream. My answer: probably run Plan9. (heh)

2017-06-13

- Grammar Puss - One possible quick-answer: because we don't conduct business in slang. Contracts writing, as well as technical spec writing requires very structured grammar. If you cannot speak/write properly, your corporate customers are likely to take their business elsewhere. Also, good luck with getting that job interview if your resume contains "jank", "dox", "fubar", and/or similar words.

2017-06-14

- 16 commands to check hardware information on Linux
- The 25 Most Disruptive Companies of the Year

2017-06-15

- Writing a Unix Shell - Part I
- mattn/sudo - Sudo for Windows? Not sure if it's a good idea but it should be about as entertaining to watch as a Windows user try to exit Vim.
- Beginner's Guide to Linkers

2017-06-17

- The calibre Content server calibre 3.0.0 documentation

2017-06-18

- Revealed: Facebook exposed identities of moderators to suspected terrorists
- Why You Should Stop Using a Raspberry Pi for Everything - This comes across as click-bait. The RPi is a learning/development tool, not infrastructure. The article leverages another article which is eaven worse (e.g., "You can't run MS Office on a Pi" is treated as a rational justification.)
- Keys Tokens and Too Much Trust Found in Container Images

2017-06-19

- Open Textbook Library
- Your own company? You can do it!
- vendu/wizardcode
- Intro to SDR and RF Signal Analysis
- 10 Free Must-Read Books for Machine Learning and Data Science
- Language summit lightning talks [LWN.net]
- DeepMind Open Source Datasets DeepMind
- Security/Guidelines/OpenSSH - MozillaWiki
- The new subtle ways the rich signal their wealth

2017-06-20

- The Stack Clash

2017-06-23

- Why So Many Top Hackers Hail from Russia Krebs on Security
- Erlang/OTP 20.0
- Academy - MLJAR - Machine learning training.
- Government wants to permanently legalize the right to repair - I've always felt that this is something that should be left to "the market". Once an industry angers its customer base, it's ripe for "disruption".
- 7 Ways to Get Better at C During this Summer

2017-06-24

- How to Call B.S. on Big Data: A Practical Guide

2017-06-25

- Audio streaming: Icecast HLS MP3
- astorfi/TensorFlow-World

2017-06-27

- AWS Security Primer
- Deep Learning in Robotics Robohub
- Over 150 of the Best Machine Learning NLP and Python Tutorials I've Found
- Quantum Computing: A beginner s notes and overview of IBM's Quantum Experience - The developerWorks Blog
- This Ikea Bowl Has Been Setting Things on Fire

2017-06-28

- European Commission - PRESS RELEASES - Press release
- 'Infarm' Startup Wants To Put a Farm In Every Grocery Store - I can't get away from the thought that this is being stood up by non-farmers. How fast do they think things grow? They're going to need a lot of space, for lengthy periods of time, with no immediate ROI.
- Canada's top court backs order for Google to remove firm's website from global searches - Yet another group of people who don't understand how search engines work. Hint: take the data off of the source and ask the search engine to re-index the site. Otherwise the data is still on the Internet. Google just won't be able to find it (but other search engines will).

2017-06-29

- 5 Cool Docker Projects You May Have Missed - Container Journal
- Sysdig Container isolation gone wrong
- Explain like I'm 5: Kerberos

2017-06-30

- Couple Asks Internet To Photoshop Out Shirtless Guy From Engagement Photo Regrets It Immediately
- What Happens When You Ask The Wrong Guy For Help 10 New Pics

Above was generated by a homegrown bolt-on script for Wallabag, which is a free utility for capturing web content so that it can be read later.