You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
# (forked from private repo from 2013)
# Original Date: 2013-03-18 16:38:04 +0000 (Mon, 18 Mar 2013)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
mkdir -pv /vagrant/logs
{
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
bash_tools="/bash-tools"
# shellcheck disable=SC1090
source "$bash_tools/lib/utils.sh"
section "Running Vagrant Shell Provisioner Script - Base"
pushd /vagrant
mkdir -p /root/.ssh
while read -r line; do
if ! [ -f /root/.ssh/authorized_keys ] ||
! grep -Fqx "$line" /root/.ssh/authorized_keys; then
echo "adding SSH authorized key to /root/.ssh/authorized_keys: $line"
echo "$line" >> /root/.ssh/authorized_keys
fi
done < <(sed 's/#.*//; /^[[:space:]]*$/d' /home/vagrant/.ssh/authorized_keys)
pushd "$bash_tools"
echo >&2
timestamp "stripping 127.0.1.1 from /etc/hosts to avoid hostname resolve clash"
sed -ibak '/127.0.1.1/d' /etc/hosts
timestamp "adding /etc/hosts entries from Vagrantfile"
./vagrant_hosts.sh /vagrant/Vagrantfile | ./grep_or_append.sh /etc/hosts
timestamp "disabling swap"
./disable_swap.sh
echo >&2
timestamp "custom shell configuration and config linking"
make link
echo >&2
packages="vim bash-completion"
timestamp "installing: $packages"
#apt-get update
#apt-get install -y vim bash-completion
# want splitting
# shellcheck disable=SC2086
./install_packages.sh $packages
} 2>&1 | tee -a /vagrant/logs/provision.log