#!/bin/bash # here be dragons... see http://fvue.nl/wiki/Bash:_Error_handling set -euxo pipefail config_fqdn=$(hostname --fqdn) config_domain=$(hostname --domain) echo "127.0.0.1 $config_fqdn" >>/etc/hosts # enable systemd-journald persistent logs. sed -i -E 's,^#?(Storage=).*,\1persistent,' /etc/systemd/journald.conf systemctl restart systemd-journald # disable IPv6. cat >/etc/sysctl.d/98-disable-ipv6.conf <<'EOF' net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 EOF systemctl restart procps sed -i -E 's,(GRUB_CMDLINE_LINUX=.+)",\1 ipv6.disable=1",' /etc/default/grub update-grub2 # update the package cache. apt-get -y update # install a EGD (Entropy Gathering Daemon). # NB the host should have an EGD and expose/virtualize it to the guest. # on libvirt there's virtio-rng which will read from the host /dev/random device # so your host should have a TRNG (True RaNdom Generator) with rng-tools # reading from it and feeding it into /dev/random or have the haveged # daemon running. # see https://wiki.qemu.org/Features/VirtIORNG # see https://wiki.archlinux.org/index.php/Rng-tools # see https://www.kernel.org/doc/Documentation/hw_random.txt # see https://hackaday.com/2017/11/02/what-is-entropy-and-how-do-i-get-more-of-it/ # see cat /sys/devices/virtual/misc/hw_random/rng_current # see cat /proc/sys/kernel/random/entropy_avail # see rngtest -c 1000 /etc/vim/vimrc.local <<'EOF' syntax on set background=dark set esckeys set ruler set laststatus=2 set nobackup autocmd BufNewFile,BufRead Vagrantfile set ft=ruby EOF # create a self-signed certificate. pushd /etc/ssl/private openssl genrsa \ -out $config_fqdn-keypair.pem \ 2048 \ 2>/dev/null chmod 400 $config_fqdn-keypair.pem openssl req -new \ -sha256 \ -subj "/CN=$config_fqdn" \ -key $config_fqdn-keypair.pem \ -out $config_fqdn-csr.pem openssl x509 -req -sha256 \ -signkey $config_fqdn-keypair.pem \ -extensions a \ -extfile <(echo "[a] subjectAltName=DNS:$config_fqdn extendedKeyUsage=serverAuth ") \ -days 365 \ -in $config_fqdn-csr.pem \ -out $config_fqdn-crt.pem openssl x509 \ -in $config_fqdn-crt.pem \ -outform der \ -out $config_fqdn-crt.der openssl x509 \ -noout \ -text \ -in $config_fqdn-crt.pem # copy the certificate to a place where it can be used by other machines. mkdir -p /vagrant/shared cp $config_fqdn-crt.* /vagrant/shared # configure our system to trust the certificate. cp $config_fqdn-crt.pem /usr/local/share/ca-certificates/$config_fqdn.crt update-ca-certificates -v popd # install and configure nginx to proxy to nexus. # see https://help.sonatype.com/en/run-behind-a-reverse-proxy.html apt-get install -y --no-install-recommends nginx wget -qO /etc/ssl/certs/dhparam.pem https://ssl-config.mozilla.org/ffdhe2048.txt sed -i -E 's/^(\s*)((ssl_protocols|ssl_ciphers|ssl_prefer_server_ciphers)\s)/\1# \2/' /etc/nginx/nginx.conf cat >/etc/nginx/conf.d/local.conf </etc/nginx/sites-available/$config_fqdn.conf <