Fix lint errors, update packer files

This commit is contained in:
Chris Long
2020-06-25 23:11:59 -07:00
parent 5c22a8a2a4
commit 21477e376a
16 changed files with 33 additions and 1170 deletions

View File

@@ -6,18 +6,18 @@ esac
# Whiteout root
count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}')
count=$(($count-1))
count=$((count-1))
dd if=/dev/zero of=/tmp/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
rm /tmp/whitespace
# Whiteout /boot
count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}')
count=$(($count-1))
count=$((count-1))
dd if=/dev/zero of=/boot/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
rm /boot/whitespace
set +e
swapuuid="`/sbin/blkid -o value -l -s UUID -t TYPE=swap`";
swapuuid="$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)";
case "$?" in
2|0) ;;
*) exit 1 ;;
@@ -27,7 +27,7 @@ set -e
if [ "x${swapuuid}" != "x" ]; then
# Whiteout the swap partition to reduce box size
# Swap is disabled till reboot
swappart="`readlink -f /dev/disk/by-uuid/$swapuuid`";
swappart="$(readlink -f /dev/disk/by-uuid/"$swapuuid")";
/sbin/swapoff "$swappart";
dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed";
/sbin/mkswap -U "$swapuuid" "$swappart";

View File

@@ -3,6 +3,7 @@
SSHD_CONFIG="/etc/ssh/sshd_config"
# ensure that there is a trailing newline before attempting to concatenate
# shellcheck disable=SC1003
sed -i -e '$a\' "$SSHD_CONFIG"
USEDNS="UseDNS no"

View File

@@ -12,15 +12,15 @@ vmware-iso|vmware-vmx)
mkdir -p /tmp/vmware;
mkdir -p /tmp/vmware-archive;
mount -o loop $HOME_DIR/linux.iso /tmp/vmware;
mount -o loop "$HOME_DIR"/linux.iso /tmp/vmware;
TOOLS_PATH="`ls /tmp/vmware/VMwareTools-*.tar.gz`";
VER="`echo "${TOOLS_PATH}" | cut -f2 -d'-'`";
MAJ_VER="`echo ${VER} | cut -d '.' -f 1`";
TOOLS_PATH="$(ls /tmp/vmware/VMwareTools-*.tar.gz)";
VER="$(echo "${TOOLS_PATH}" | cut -f2 -d'-')";
MAJ_VER="$(echo "${VER}" | cut -d '.' -f 1)";
echo "VMware Tools Version: $VER";
tar xzf ${TOOLS_PATH} -C /tmp/vmware-archive;
tar xzf "${TOOLS_PATH}" -C /tmp/vmware-archive;
if [ "${MAJ_VER}" -lt "10" ]; then
/tmp/vmware-archive/vmware-tools-distrib/vmware-install.pl --default;
else
@@ -29,6 +29,6 @@ vmware-iso|vmware-vmx)
umount /tmp/vmware;
rm -rf /tmp/vmware;
rm -rf /tmp/vmware-archive;
rm -f $HOME_DIR/*.iso;
rm -f "$HOME_DIR"/*.iso;
;;
esac

View File

@@ -12,7 +12,7 @@ dpkg --list \
dpkg --list \
| awk '{ print $2 }' \
| grep 'linux-image-.*-generic' \
| grep -v `uname -r` \
| grep -v "$(uname -r)" \
| xargs apt-get -y purge;
# Delete Linux source

View File

@@ -1,7 +1,7 @@
#!/bin/sh -eux
ubuntu_version="`lsb_release -r | awk '{print $2}'`";
major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
ubuntu_version="$(lsb_release -r | awk '{print $2}')";
major_version="$(echo "$ubuntu_version" | awk -F. '{print $1}')";
if [ "$major_version" -ge "18" ]; then
echo "Create netplan config for eth0"

View File

@@ -1,8 +1,8 @@
#!/bin/sh -eux
export DEBIAN_FRONTEND=noninteractive
ubuntu_version="`lsb_release -r | awk '{print $2}'`";
major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
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;

View File

@@ -1,14 +1,14 @@
#!/bin/bash -eux
pubkey_url="https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub";
mkdir -p $HOME_DIR/.ssh;
mkdir -p "$HOME_DIR"/.ssh;
if command -v wget >/dev/null 2>&1; then
wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys;
wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/.ssh/authorized_keys;
elif command -v curl >/dev/null 2>&1; then
curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys;
curl --insecure --location "$pubkey_url" > "$HOME_DIR"/.ssh/authorized_keys;
else
echo "Cannot download vagrant public key";
exit 1;
fi
chown -R vagrant $HOME_DIR/.ssh;
chmod -R go-rwsx $HOME_DIR/.ssh;
chown -R vagrant "$HOME_DIR"/.ssh;
chmod -R go-rwsx "$HOME_DIR"/.ssh;

View File

@@ -92,8 +92,7 @@
"esxi_host": "",
"esxi_username": "",
"esxi_password": "",
"iso_checksum": "ab4862ba7d1644c27f27516d24cb21e6b39234eb3301e5f1fb365a78b22f79b3",
"iso_checksum_type": "sha256",
"iso_checksum": "sha256:ab4862ba7d1644c27f27516d24cb21e6b39234eb3301e5f1fb365a78b22f79b3",
"iso_url": "https://software-download.microsoft.com/download/pr/18362.30.190401-1528.19h1_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso",
"autounattend": "../../Packer/answer_files/10/Autounattend.xml",
"disk_size": "61440"

View File

@@ -80,8 +80,7 @@
"esxi_username": "",
"esxi_password": "",
"iso_url": "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO",
"iso_checksum_type": "md5",
"iso_checksum": "70721288BBCDFE3239D8F8C0FAE55F1F",
"iso_checksum": "md5:70721288BBCDFE3239D8F8C0FAE55F1F",
"autounattend": "../../Packer/answer_files/2016/Autounattend.xml"
}
}