Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Last active March 17, 2022 00:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwilczynski/335941ce51a1f3ca8f54 to your computer and use it in GitHub Desktop.
Save kwilczynski/335941ce51a1f3ca8f54 to your computer and use it in GitHub Desktop.
/etc/update-motd.d/90-vagrant -- dynamic Message of the Day with added Vagrant information (brief)
#!/bin/sh
[ -f /etc/os-release-vagrant ] || exit 0
# Add information about this particular Vagrant box e.g., version, etc.
. /etc/os-release-vagrant
# Calculate the level of indentation.
_indent() { echo "(${#1} + 75) / 2" | bc; }
readonly HEADER="$BUILD_NAME (${BUILDER_TYPE})"
readonly VERSION="Box version: ${VERSION}"
printf "\n%*s\n" "$(_indent "$HEADER")" "$HEADER"
cat <<'EOS'
_____ _____ _____ _____ _____ _____ _____
| | | _ | __| __ | _ | | |_ _|
| | | | | | -| | | | | | |
\___/|__|__|_____|__|__|__|__|_|___| |_|
EOS
printf "%*s\n%*s\n" \
"$(_indent "$BUILD_DATE")" "$BUILD_DATE" \
"$(_indent "${VERSION}")" "$VERSION"
exit 0
BUILD_NAME="ubuntu-14.04-amd64"
BUILD_NUMBER=0
BUILD_TIMESTAMP=1424534915
BUILD_DATE="Sat Feb 21 16:08:35 UTC 2015"
BUILDER_TYPE="vmware"
VERSION="0.1.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment