#!/bin/bash -e set -xeo pipefail # For SHASUM apt-get -y install perl ifupdown # Download OpenNebula context package ONE_CONTEXT_VERSION=5.8.0 ONE_CONTEXT_BUILD_SUFFIX=-1 ONE_CONTEXT_SHASUM=cfcc8aa2e51396935e8d2a507f996838201515b5 ONE_CONTEXT_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v${ONE_CONTEXT_VERSION}/one-context_${ONE_CONTEXT_VERSION}${ONE_CONTEXT_BUILD_SUFFIX}.deb" ONE_CONTEXT_PACKAGE_DEST=/tmp/one-context.deb wget -O- "${ONE_CONTEXT_URL}" > "${ONE_CONTEXT_PACKAGE_DEST}" echo "${ONE_CONTEXT_SHASUM} ${ONE_CONTEXT_PACKAGE_DEST}" | shasum -c # Purge cloud-init apt-get purge -y cloud-init perl # Install onecontext dpkg -i "${ONE_CONTEXT_PACKAGE_DEST}" || apt-get install -fy # Update hostname hostnamectl set-hostname "${VM_NAME}" # Disable root login with password # sed -i 's/^PermitRootLogin.*$/PermitRootLogin without-password/' /etc/ssh/sshd_config # Run dhclient on one-context service failure mkdir -p /etc/systemd/system/one-context.service.d cat > /etc/systemd/system/one-context.service.d/dhclient-on-fail.conf < /etc/systemd/system/one-dhclient.service <