Refresh ubuntu-14.04
Closes-Bug: PROD-21397 (PROD:21397)
Change-Id: I5a7717e26c016bd5a89d9cb1031dca7c14299050
diff --git a/ubuntu-14.04/scripts/base.sh b/ubuntu-14.04/scripts/base.sh
deleted file mode 100644
index 439c5a4..0000000
--- a/ubuntu-14.04/scripts/base.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-## Base packages and setup
-export DEBIAN_FRONTEND=noninteractive
-echo "exit 101" > /usr/sbin/policy-rc.d
-chmod +x /usr/sbin/policy-rc.d
-
-echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
-
-# Overwrite default mirrors
-echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted multiverse universe" > /etc/apt/sources.list
-echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted multiverse universe" >> /etc/apt/sources.list
-echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted multiverse universe" >> /etc/apt/sources.list
-echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted multiverse universe" >> /etc/apt/sources.list
-
-# Add apt repository
-echo "deb [arch=amd64] http://apt.mirantis.com/trusty/ nightly salt" > /etc/apt/sources.list.d/mcp_salt.list
-echo "deb [arch=amd64] http://apt.mirantis.com/trusty/ nightly extra" > /etc/apt/sources.list.d/mcp_extra.list
-curl -sf http://apt.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
- apt-get install -y linux-generic-lts-xenial
-
- # Update grub cmdline
- sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
- sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
- update-grub
-fi
-
-apt-get -y upgrade
-apt-get -y dist-upgrade
-
-apt-get autoremove --purge
-
-# Tmux fixes
-cat << 'EOF' >> /etc/tmux.conf
-set -g default-terminal "screen-256color"
-set -g set-titles on
-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 -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 14.04 \"Trusty\" Mirantis cloud image"
-echo "Build date: ${BUILD_TIMESTAMP_RFC}"
-EOF
-chmod +x /etc/update-motd.d/00-header-mirantis
diff --git a/ubuntu-14.04/scripts/base.sh b/ubuntu-14.04/scripts/base.sh
new file mode 120000
index 0000000..7df0165
--- /dev/null
+++ b/ubuntu-14.04/scripts/base.sh
@@ -0,0 +1 @@
+../../common/ubuntu_trusty_base.sh
\ No newline at end of file
diff --git a/ubuntu-14.04/scripts/cleanup.sh b/ubuntu-14.04/scripts/cleanup.sh
deleted file mode 100644
index 7f2ba4d..0000000
--- a/ubuntu-14.04/scripts/cleanup.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-apt-get -y autoremove --purge
-apt-get -y clean
-rm -f /var/lib/apt/lists/*
-
-rm -f /usr/sbin/policy-rc.d || true
-
-echo "cleaning up hostname"
-sed -i "/.*ubuntu-1404.*/d" /etc/hosts
-
-echo "cleaning up guest additions"
-rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
-
-echo "cleaning up dhcp leases"
-rm -f /var/lib/dhcp/* || true
-
-echo "cleaning up udev rules"
-rm -f /etc/udev/rules.d/70-persistent-net.rules || true
-rm -rf /dev/.udev/ || true
-rm -f /lib/udev/rules.d/75-persistent-net-generator.rules || true
-
-echo "cleaning up minion_id for salt"
-rm -f /etc/salt/minion_id || true
-
diff --git a/ubuntu-14.04/scripts/cleanup.sh b/ubuntu-14.04/scripts/cleanup.sh
new file mode 120000
index 0000000..cf970b6
--- /dev/null
+++ b/ubuntu-14.04/scripts/cleanup.sh
@@ -0,0 +1 @@
+../../common/ubuntu_cleanup.sh
\ No newline at end of file
diff --git a/ubuntu-14.04/scripts/docker.sh b/ubuntu-14.04/scripts/docker.sh
index 9ae4add..bd79ed8 100644
--- a/ubuntu-14.04/scripts/docker.sh
+++ b/ubuntu-14.04/scripts/docker.sh
@@ -1,5 +1,6 @@
# This should simulate preseed behavior
+apt-get update
apt-get -y install curl
# Add apt repository
@@ -7,6 +8,7 @@
echo "deb [arch=amd64] http://apt.mirantis.com/trusty/ nightly extra" > /etc/apt/sources.list.d/mcp_extra.list
curl -sf http://apt.mirantis.com/public.gpg | apt-key add -
+apt-get clean
apt-get update
# Kernel makes no sense in docker, let base.sh know
diff --git a/ubuntu-14.04/scripts/info.sh b/ubuntu-14.04/scripts/info.sh
new file mode 120000
index 0000000..772d054
--- /dev/null
+++ b/ubuntu-14.04/scripts/info.sh
@@ -0,0 +1 @@
+../../common/ubuntu_info.sh
\ No newline at end of file
diff --git a/ubuntu-14.04/scripts/motd.sh b/ubuntu-14.04/scripts/motd.sh
new file mode 100644
index 0000000..e215a29
--- /dev/null
+++ b/ubuntu-14.04/scripts/motd.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -xe
+# 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 \"Trusty\" Mirantis cloud image"
+echo "Build date: ${BUILD_TIMESTAMP_RFC}"
+EOF
+chmod +x /etc/update-motd.d/00-header-mirantis
+
diff --git a/ubuntu-14.04/scripts/network.sh b/ubuntu-14.04/scripts/network.sh
new file mode 120000
index 0000000..ab1de37
--- /dev/null
+++ b/ubuntu-14.04/scripts/network.sh
@@ -0,0 +1 @@
+../../common/ubuntu_network.sh
\ No newline at end of file
diff --git a/ubuntu-14.04/scripts/salt.sh b/ubuntu-14.04/scripts/salt.sh
index b5d5813..4228bb8 100644
--- a/ubuntu-14.04/scripts/salt.sh
+++ b/ubuntu-14.04/scripts/salt.sh
@@ -1,9 +1,19 @@
-wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
-echo "deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/2016.3 trusty main" >/etc/apt/sources.list.d/saltstack.list
+#!/bin/bash -xe
+
+SALTSTACK_REPO=${SALTSTACK_REPO:-"deb [arch=amd64] https://mirror.mirantis.com/stable/saltstack-2017.7/trusty/ trusty main"}
+SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"}
+
+wget -O - ${SALTSTACK_GPG} | sudo apt-key add -
+echo "${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list
+
+# We expect issues with GPG,related to our mirrors - so temporary disable check.
+echo "APT::Get::AllowUnauthenticated true;" > /etc/apt/apt.conf.d/99allow_unauthenticated
+
apt-get update
apt-get -y install salt-minion
mkdir -m700 -p /etc/salt/pki/minion
-echo "
+
+cat <<EOF >> /etc/salt/minion.d/minion.conf
max_event_size: 100000000
acceptance_wait_time_max: 60
acceptance_wait_time: 10
@@ -11,4 +21,8 @@
recon_default: 1000
recon_max: 60000
recon_randomize: True
-auth_timeout: 60" >> /etc/salt/minion
+auth_timeout: 60
+EOF
+
+rm -vf /etc/apt/apt.conf.d/99allow_unauthenticated
+rm -vf /etc/apt/sources.list.d/saltstack.list
diff --git a/ubuntu-14.04/scripts/security.sh b/ubuntu-14.04/scripts/security.sh
deleted file mode 100644
index 3026626..0000000
--- a/ubuntu-14.04/scripts/security.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-# Auto login root on tty1
-sed -i 's|/sbin/getty|/sbin/getty --autologin root|g' /etc/init/tty1.conf
-
-# Libvirt serial console support
-cat << 'EOF' >> /etc/init/ttyS0.conf
-# ttyS0 - getty
-#
-# This service maintains a getty on tty1 from the point the system is
-# started until it is shut down again.
-
-start on stopped rc RUNLEVEL=[2345] and (
- not-container or
- container CONTAINER=lxc or
- container CONTAINER=lxc-libvirt)
-
-stop on runlevel [!2345]
-
-respawn
-exec /sbin/getty --autologin root -8 115200 ttyS0 xterm
-EOF
-
-# Disable password root login
-usermod -p '!' root
-
-# Disable SSH password authentication and permit root login
-sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
-sed -i 's|[#]*PermitRootLogin no|PermitRootLogin yes|g' /etc/ssh/sshd_config
diff --git a/ubuntu-14.04/scripts/security.sh b/ubuntu-14.04/scripts/security.sh
new file mode 120000
index 0000000..31e630f
--- /dev/null
+++ b/ubuntu-14.04/scripts/security.sh
@@ -0,0 +1 @@
+../../common/ubuntu_trusty_security.sh
\ No newline at end of file