Content-Type: multipart/mixed; boundary="===============8645434374073493512==" MIME-Version: 1.0 --===============8645434374073493512== MIME-Version: 1.0 Content-Type: text/cloud-config; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config # Enable root and password auth disable_root: false ssh_pwauth: false # Allow cloud-init to manage /etc/hosts manage_etc_hosts: true # Set the default user to root and define the package mirrors system_info: distro: ubuntu default_user: name: root shell: /bin/bash lock_passwd: false package_mirrors: - arches: [i386, amd64] failsafe: primary: http://archive.ubuntu.com/ubuntu security: http://security.ubuntu.com/ubuntu search: primary: - http://mirrors.digitalocean.com/ubuntu/ security: [] --===============8645434374073493512== MIME-Version: 1.0 Content-Type: text/cloud-boothook; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="resolver-fix" #!/bin/sh -x # DigitalOcean resolver fixup script cloud-init-per instance do-resolved-conf /bin/false && exit 0 [ -f /etc/systemd/resolved.conf ] || grep -q 'Fedora Linux 40' /etc/os-release || exit 0 logger -t DigitalOcean 'writing resolvers to /etc/systemd/resolved.conf.d/DigitalOcean.conf' mkdir -p /etc/systemd/resolved.conf.d printf "[Resolve]\nDNS=67.207.67.3 67.207.67.2\n" > /etc/systemd/resolved.conf.d/DigitalOcean.conf systemctl try-reload-or-restart systemd-resolved --===============8645434374073493512== MIME-Version: 1.0 Content-Type: text/cloud-boothook; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="entropy-seed" #!/bin/sh -x # DigitalOcean Entropy Seed script logger -t DigitalOcean 'adding random seed to /dev/urandom' (base64 -d < /dev/urandom --===============8645434374073493512== MIME-Version: 1.0 Content-Type: text/cloud-boothook; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="digitalocean_fixups" #!/bin/sh # These are udev rules and scripts that are placed here for the sake of readability # later in this script. no_systemd_mount_rules=$(cat <<'EOM' # Only try to automount DO block volumes. SUBSYSTEM!="block", GOTO="do_automount_end" ENV{ID_VENDOR}!="DO", GOTO="do_automount_end" ENV{ID_MODEL}!="Volume", GOTO="do_automount_end" # Only automount on the "add" action. ACTION!="add", GOTO="do_automount_end" # Only try to automount filesystems we know about. ENV{ID_FS_TYPE}!="ext4|xfs", GOTO="do_automount_end" # Create a temporary mountpoint and temporary location for the first-mount script. IMPORT{program}="/bin/sh -c 'echo TMP_MOUNT_DIR=$(mktemp -d -p /mnt .do-first-mount-XXXXXXXXX)'" # Handle temporary mountpoint creation failure. ENV{TMP_MOUNT_DIR}=="", GOTO="do_automount_end" IMPORT{program}="/bin/sh -c 'echo TMP_SCRIPT=$(mktemp -t .do-first-mount-XXXXXXXXX.sh)'" # Handle temporary script location creation failure. ENV{TMP_SCRIPT}=="", PROGRAM="/bin/sh -c '/bin/rmdir %E{TMP_MOUNT_DIR} || exit 0'", GOTO="do_automount_end" # Mount the volume at the temp mountpoint and copy the script off, then unmount. RUN{program}+="/bin/mount -o ro /dev/%k %E{TMP_MOUNT_DIR}" RUN{program}+="/bin/sh -c '/bin/cp %E{TMP_MOUNT_DIR}/.first-mount.sh %E{TMP_SCRIPT} || exit 0'" RUN{program}+="/bin/umount %E{TMP_MOUNT_DIR}" RUN{program}+="/bin/rmdir %E{TMP_MOUNT_DIR}" # Run the first-mount script. If it didn't exist this will be a no-op. RUN{program}+="/bin/sh %E{TMP_SCRIPT} '%E{ID_SERIAL}' '%E{ID_FS_TYPE}' '%E{ID_SERIAL_SHORT}' '%E{ID_FS_UUID}' '%E{ID_FS_LABEL}'" # Clean up. RUN{program}+="/bin/rm %E{TMP_SCRIPT}" # Finally, try and mount the volume. On first mount this will fail, but that's # OK because the volume was already mounted by the first-mount script. RUN{program}+="/bin/sh -c '/bin/mount /dev/%k || exit 0'" LABEL="do_automount_end" EOM ) systemd_mount_rules=$(cat <<'EOM' # Only try to automount DO block volumes. SUBSYSTEM!="block", GOTO="do_automount_end" ENV{ID_VENDOR}!="DO", GOTO="do_automount_end" ENV{ID_MODEL}!="Volume", GOTO="do_automount_end" # Only automount on "add" or "change" actions. ACTION!="add|change", GOTO="do_automount_end" # Only try to automount filesystems we know about. ENV{ID_FS_TYPE}!="ext4|xfs", GOTO="do_automount_end" # Create a temporary location for the first-mount script. IMPORT{program}="/bin/sh -c 'echo TMP_SCRIPT=$$(mktemp -t .do-first-mount-XXXXXXXXX.sh)'" # Handle temporary script location creation failure. ENV{TMP_SCRIPT}=="", GOTO="do_automount_end" RUN{program}+="/var/lib/cloud/scripts/per-instance/systemd_automount.sh %k %E{TMP_SCRIPT} '%E{ID_SERIAL}' '%E{ID_FS_TYPE}' '%E{ID_SERIAL_SHORT}' '%E{ID_FS_UUID}' '%E{ID_FS_LABEL}'" LABEL="do_automount_end" EOM ) systemd_mount_script=$(cat <<'EOM' #!/bin/bash DEVICE=$1 TMP_SCRIPT=$2 ID_SERIAL=$3 ID_FS_TYPE=$4 ID_SERIAL_SHORT=$5 ID_FS_UUID=$6 ID_FS_LABEL=$7 function cleanup() { if [ -f "${TMP_SCRIPT}" ]; then rm -f "${TMP_SCRIPT}" fi } trap cleanup EXIT # If device is blank or unset exit. Can happen on first start if [ -z "$DEVICE" ]; then exit 0 fi devpath="/dev/${DEVICE}" # New first-mount approach magic_size=14 size=$(( 512 * $(cat /sys/block/${DEVICE}/size) )) offset=$(( ${size} - ${magic_size} )) magic=$(dd if="${devpath}" bs=${magic_size} count=1 skip=${offset} iflag=skip_bytes 2>/dev/null | tr -d '\000') if [ "${magic}" == "DO_FIRST_MOUNT" ]; then logger -t digitalocean-automount "detected first mount magic" # Clear magic so this script won't trigger again dd if=/dev/zero of="${devpath}" bs=${magic_size} count=1 seek=${offset} oflag=seek_bytes 2>/dev/null # First mount trailer format: #