fabrica/.packer/recipes/eole/2.7.2/provision.sh

77 lines
2.0 KiB
Bash
Raw Normal View History

#!/bin/bash -e
set -xeo pipefail
export DEBIAN_FRONTEND=noninteractive
# 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
# Install onecontext
Query-Auto
dpkg -i "${ONE_CONTEXT_PACKAGE_DEST}" || apt-get install -fy
# Ajout script de compat contextualisation OpenNebula/EOLE
apt-get install -y jq
mv /root/net-99-eole /etc/one-context.d/net-99-eole
chmod +x /etc/one-context.d/net-99-eole
# Allow TCP Forwarding to ease GenConfig usage
sed 's/^AllowTcpForwarding.*$/AllowTcpForwarding yes/' /usr/share/eole/creole/distrib/sshd_config > /usr/share/eole/creole/modif/sshd_config
# Ajout patch configuration DHCPv6
mv /root/00-eole.yaml /usr/share/eole/creole/modif/00-eole.yaml
gen_patch
# Update hostname
hostnamectl set-hostname "${VM_NAME}"
# Disable root login with password
# sed -i 's/^PermitRootLogin.*$/PermitRootLogin without-password/' /etc/ssh/sshd_config
# Cleanup
rm -f "${ONE_CONTEXT_PACKAGE_DEST}"
apt-get -y clean
# Update image with latest packages
Maj-Auto -i
# Clean all apt cache
apt clean
# TEMP Prevent EOLE 2.7.0 fucking bugs
systemctl disable gpm # Allow fucking login in VNC
# Disable nut-(driver|monitor)
systemctl mask nut-driver
systemctl disable nut-monitor
# Disable IPv6 to allow the VM to fucking boot
sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"/' /etc/default/grub
update-grub
# TRIM command to reduce disk size
fstrim -av
# Zero out the disk (could be very long)
set +e
FILE=/mytempfile
dd if=/dev/zero of=${FILE}
rm -rf ${FILE}
sync
set -e
# Force sync
sync