Adding self installation command for fabrica

This commit is contained in:
2021-03-23 10:47:39 +01:00
parent 740a8de4a2
commit b360760855
120 changed files with 301 additions and 164 deletions

View File

@ -0,0 +1,57 @@
#!/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 <<EOF
[Unit]
OnFailure=one-dhclient.service
EOF
cat > /etc/systemd/system/one-dhclient.service <<EOF
[Unit]
Description=Execute dhclient
[Service]
ExecStart=/sbin/dhclient
EOF
chmod 664 /etc/systemd/system/one-dhclient.service
# Disable auto-upgrade
systemctl disable unattended-upgrades
systemctl disable apt-daily
systemctl disable apt-daily.timer
systemctl disable apt-daily-upgrade
# Cleanup
rm -f "${ONE_CONTEXT_PACKAGE_DEST}"
apt-get -y clean
# Force sync
sync