Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 128 lines (103 sloc) 3.39 KB
#!/bin/sh -eux
##
## Basic Software installation
##
export DEBIAN_FRONTEND=noninteractive
ubuntu_version="`lsb_release -r | awk '{print $2}'`";
major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
# Disable release-upgrades
sed -i.bak 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades;
# Disable systemd apt timers/services
if [ "$major_version" -ge "16" ]; then
systemctl stop apt-daily.timer;
systemctl stop apt-daily-upgrade.timer;
systemctl disable apt-daily.timer;
systemctl disable apt-daily-upgrade.timer;
systemctl mask apt-daily.service;
systemctl mask apt-daily-upgrade.service;
systemctl daemon-reload;
fi
# Disable periodic activities of apt to be safe
cat <<EOF >/etc/apt/apt.conf.d/10periodic;
APT::Periodic::Enable "0";
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
EOF
# Clean and nuke the package from orbit
rm -rf /var/log/unattended-upgrades;
apt-get -y purge unattended-upgrades;
## Disabled updates, make sure the base iso is recent enough instead
## Update the package list
##apt-get -y update;
#
## Upgrade all installed packages incl. kernel and kernel headers
##apt-get -y dist-upgrade -o Dpkg::Options::="--force-confnew";
##
## Optimize SSHD Performance inside VMs
##
SSHD_CONFIG="/etc/ssh/sshd_config"
# ensure that there is a trailing newline before attempting to concatenate
sed -i -e '$a\' "$SSHD_CONFIG"
USEDNS="UseDNS no"
if grep -q -E "^[[:space:]]*UseDNS" "$SSHD_CONFIG"; then
sed -i "s/^\s*UseDNS.*/${USEDNS}/" "$SSHD_CONFIG"
else
echo "$USEDNS" >>"$SSHD_CONFIG"
fi
GSSAPI="GSSAPIAuthentication no"
if grep -q -E "^[[:space:]]*GSSAPIAuthentication" "$SSHD_CONFIG"; then
sed -i "s/^\s*GSSAPIAuthentication.*/${GSSAPI}/" "$SSHD_CONFIG"
else
echo "$GSSAPI" >>"$SSHD_CONFIG"
fi
##
## Optimize Network Setup
##
if [ "$ubuntu_version" = '17.10' ] || [ "$major_version" -ge "18" ]; then
echo "Create netplan config for eth0"
cat <<EOF >/etc/netplan/01-netcfg.yaml;
network:
version: 2
ethernets:
eth0:
dhcp4: true
EOF
else
# Adding a 2 sec delay to the interface up, to make the dhclient happy
echo "pre-up sleep 2" >> /etc/network/interfaces;
fi
if [ "$major_version" -ge "16" ]; then
# Disable Predictable Network Interface names and use eth0
sed -i 's/en[[:alnum:]]*/eth0/g' /etc/network/interfaces;
sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 \1"/g' /etc/default/grub;
update-grub;
fi
##
## Allow Passwordless sudo for artifact user
##
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=sudo' /etc/sudoers;
# Set up password-less sudo for the artifact user
echo 'artifact ALL=(ALL) NOPASSWD:ALL' >/etc/sudoers.d/99_artifact;
chmod 440 /etc/sudoers.d/99_artifact;
##
## Install VirtualBox Guest Additions
##
# set a default HOME_DIR environment variable if not set
HOME_DIR="${HOME_DIR:-/home/artifact}";
VER="`cat $HOME_DIR/.vbox_version`";
ISO="VBoxGuestAdditions_$VER.iso";
mkdir -p /tmp/vbox;
mount -o loop $HOME_DIR/$ISO /tmp/vbox;
sh /tmp/vbox/VBoxLinuxAdditions.run \
|| echo "VBoxLinuxAdditions.run exited $? and is suppressed." \
"For more read https://www.virtualbox.org/ticket/12479";
umount /tmp/vbox;
rm -rf /tmp/vbox;
rm -f $HOME_DIR/*.iso;
##
## Set Hostname
##
echo artifact > /etc/hostname
sed -i 's/preseed/artifact/g' /etc/hosts
You can’t perform that action at this time.