From db01dec0a42840b38c7d29c02c0416a97d9e2958 Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Fri, 12 Feb 2016 13:58:06 -0800 Subject: [PATCH] Reset /etc/motd to include version, a pointer to source image and GitHub Companion to #21031 --- cluster/gce/configure-vm.sh | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 9bdb16b2aab..bf850c58e45 100755 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -74,8 +74,37 @@ function set-broken-motd() { echo -e '\nBroken (or in progress) Kubernetes node setup! Suggested first step:\n tail /var/log/startupscript.log\n' > /etc/motd } -function set-good-motd() { - echo -e '\n=== Kubernetes node setup complete ===\n' > /etc/motd +function reset-motd() { + # kubelet is installed both on the master and nodes, and the version is easy to parse (unlike kubectl) + local -r version="$(/usr/local/bin/kubelet --version=true | cut -f2 -d " ")" + # This regex grabs the minor version, e.g. v1.2. + local -r minor="$(echo ${version} | sed -r "s/(v[0-9]+\.[0-9]+).*/\1/g")" + # This logic grabs either a release tag (v1.2.1 or v1.2.1-alpha.1), + # or the git hash that's in the build info. + local gitref="$(echo "${version}" | sed -r "s/(v[0-9]+\.[0-9]+\.[0-9]+)(-[a-z]+\.[0-9]+)?.*/\1\2/g")" + local devel="" + if [[ "${gitref}" != "${version}" ]]; then + devel=" +Note: This looks like a development version, which might not be present on GitHub. +If it isn't, the closest tag is at: + https://github.com/kubernetes/kubernetes/tree/${gitref} +" + gitref="${version//*+/}" + fi + cat > /etc/motd <