Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

neechbear/blip

Repository files navigation

Build Status Code Climate Issue Count Pre-release Alpha

blip - Bash Library for Indolent Programmers

Programmers are lazy. Good system administrators are really lazy. (Why bother doing something more than once)?

Unfortunately, due to the fact that Bash doesn't particularly lend itself to reusable code, it doesn't enjoy the same wealth of shared code available that you find with Python or Perl.

"But what about the lazy sysadmin that needs to write a script, where Bash genuinely is the most appropriate option?", I hear you ask! Well, by providing functions for many common tasks, I'm hoping that blip will help fill some of the gaps for those situations.

source /usr/lib/blip.bash
# Alternate path for macOS Homebrew installations:
#source /usr/local/lib/blip.bash

Please see the man page man blip.bash, blip.bash.3.md for full documentation or /usr/share/doc/blip directory for code examples and other useful information.

Installation

Ubuntu

On Ubuntu, you can install from my PPA ppa:nicolaw/blip by running the following commands:

sudo add-apt-repository ppa:nicolaw/blip
sudo apt-get update
sudo apt-get install blip

Debian

On Debian or other Debian-based distributions, you can download the DEB package from GitHub and install it manually with:

# Determine release latest DEB package URL.
blip_deb_url="$(curl -sSL \
  "https://api.github.com/repos/neechbear/blip/releases/latest" \
    | jq -r '.assets[] | select(.name|match(".deb$";"i")).browser_download_url')"
# Download and install latest release DEB package.
curl -sSLO "$blip_deb_url"
sudo dpkg -i "${blip_deb_url##*/}"

RedHat, CentOS, Fedora

Similarly for RedHat based distributions you can install the RPM package from GitHub manually with:

# Determine release latest RPM package URL.
blip_rpm_url="$(curl -sSL \
  "https://api.github.com/repos/neechbear/blip/releases/latest" \
    | jq -r '.assets[] | select(.name|match(".rpm$";"i")).browser_download_url')"
# Download and install latest release RPM package.
curl -sSLO "$blip_rpm_url"
sudo yum localinstall "${blip_rpm_url##*/}"

macOS Homebrew

A Homebrew formula for Blip is maintained in the neechbear/tap tap.

brew tap neechbear/tap
brew install neechbear/tap/blip
brew list blip

Blip will typically be installed into the /usr/local/Cellar/blip/ cellar, and symlinked from /usr/local/lib/blip.bash.

Source

Souce installation can be achieved either by cloning the GitHub repository, or (preferably) by downloading the latest release tarball from GitHub:

# Determine release latest tarball URL.
blip_tar_url="$(curl -sSL \
  "https://api.github.com/repos/neechbear/blip/releases/latest" \
    | jq -r '.assets[] | select(.name|match("blip-[0-9]+.[0-9]+.tar.gz$";"i")).browser_download_url')"
# Download latest release tarball.
curl -sSLO "$blip_tar_url"
# Extract and install Blip from tarball.
tar -zxf "${blip_tar_url##*/}"
cd blip-*/
sudo make install

Links

TODO

  • Merge all the other cool and reusable stuff I've written in to this library (see pending functionality below).
  • Make all the shell scripting comply with a sensible style guide (like Google's one at https://google.github.io/styleguide/shell.xml).
  • Finish writing comprehensive manual page with code examples for each function.
  • Finish writing comprehensive unit tests with full code coverage.
  • Setup automatic build of release tarballs, Deb and RPM packages upon GitHub repository commits (assuming a Travis CI pass of unit tests).
  • Maybe create pkg, apk and portage packages if I get bored.
  • Add get_user_input() - multi character user input without defaults.
  • Add process locking functions.
  • Add background daemonisation functions (ewww; ppl should use systemd).
  • Add standard logging functions.
  • Add syslogging functionality of all process STDOUT + STDERR.
  • Add common array manipulation functions.