Skip to content

Instantly share code, notes, and snippets.

@tomasbasham
Created May 16, 2022 18:50
Show Gist options
  • Select an option

  • Save tomasbasham/38511cca82c1fd8017d882e7d75eff12 to your computer and use it in GitHub Desktop.

Select an option

Save tomasbasham/38511cca82c1fd8017d882e7d75eff12 to your computer and use it in GitHub Desktop.

Revisions

  1. tomasbasham created this gist May 16, 2022.
    23 changes: 23 additions & 0 deletions install_cloud_init.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/usr/bin/env bash

    set -e

    # Ensure the script is running as root
    if [[ "$(id -u)" != '0' ]]; then
    exec sudo "$BASH_SOURCE" "$@"
    fi

    # Update the system
    echo "===> Updating system"
    dnf upgrade -y --refresh

    # Check cloud-init is not already installed
    if ! commad -v cloud-init &> /dev/null; then
    echo "===> Installing cloud-init"
    dnf install -y cloud-init
    fi

    # Make sure cloud-init is invoked when the system next initialises.
    cloud-init clean

    echo "===> Done"