Update ubuntu scripts

  * Use mirrors proto for upstream repos
  * Fix and extend motd
    - motd was in wrong format(base.sh)
      that propagate error messages at boot
  * make template json-pretty

Change-Id: I71f41240fa987ff11a605cc9237e4482794053cd
diff --git a/ubuntu-16.04/scripts/base.sh b/ubuntu-16.04/scripts/base.sh
index 5daa726..6a9c2d3 100644
--- a/ubuntu-16.04/scripts/base.sh
+++ b/ubuntu-16.04/scripts/base.sh
@@ -2,17 +2,26 @@
 export DEBIAN_FRONTEND=noninteractive
 echo "exit 101" > /usr/sbin/policy-rc.d
 chmod +x /usr/sbin/policy-rc.d
-apt-get clean
-apt-get update
 
-# Useful tools
-apt-get -y install curl wget tmux vim-nox byobu iputils-ping traceroute htop tree lsof
+# Overwrite default mirrors
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted multiverse universe" > /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted multiverse universe" >> /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list
 
 # Add apt-mk repository
 echo "deb [arch=amd64] http://apt-mk.mirantis.com/xenial/ nightly salt" > /etc/apt/sources.list.d/mcp_salt.list
 echo "deb [arch=amd64] http://apt-mk.mirantis.com/xenial/ nightly extra" > /etc/apt/sources.list.d/mcp_extra.list
 curl -sf http://apt-mk.mirantis.com/public.gpg | apt-key add -
 
+apt-get clean
+apt-get update
+
+# Useful tools
+apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
+# Install common prerequisites
+apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil
+
 # Cleanup old kernels, ensure latest is installed via virtual package
 apt-get purge -y linux-image-* linux-headers-*
 if [ ! -f /tmp/no_install_kernel ]; then
@@ -39,21 +48,25 @@
 set -g xterm-keys on
 EOF
 
-# Install common prerequisites
-apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil
-
 # Setup cloud-init
 apt-get -y install cloud-init
 
-# Motd
-apt-get install -y update-motd
-rm -f /etc/update-motd.d/*
-cat << EOF >> /etc/update-motd.d/52-info
-Ubuntu 16.04 "Xenial" Mirantis cloud image
-Build date: $(date -u -R)
-
-EOF
-chmod +x /etc/update-motd.d/52-info
-
 # Disable apt-daily
-systemctl disable apt-daily.timer
\ No newline at end of file
+systemctl disable apt-daily.timer
+
+# Motd
+apt-get -y install update-motd
+rm -vf /etc/update-motd.d/*
+echo "BUILD_TIMESTAMP=$(date '+%Y-%m-%d-%H-%M-%S' -u)" > /etc/image_version
+echo "BUILD_TIMESTAMP_RFC=\"$(date -u -R)\"" >> /etc/image_version
+cat << 'EOF' >> /etc/update-motd.d/00-header-mirantis
+#!/bin/sh
+#
+#    00-header - create the header of the MOTD
+#
+[ -r /etc/image_version ] && . /etc/image_version
+echo "Ubuntu 16.04 \"Xenial\" Mirantis cloud image"
+echo "Build date: ${BUILD_TIMESTAMP_RFC}"
+EOF
+chmod +x /etc/update-motd.d/00-header-mirantis
+