Last active
November 5, 2025 07:16
-
-
Save c0nscience/fefcbfc313b42c2e09ba983c18ac304b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| set -euo pipefail | |
| RESET="\e[0m" | |
| BOLD="\e[1;37m" | |
| real_name="Benjamin Herzig" | |
| username="bhe" | |
| hostname="BHE-NB3" | |
| AUTOINSTALL_FILE_PATH="$PWD"/ubuntu-autoinstall.yaml | |
| check_has_installed() { | |
| if ! command -v "$1" &>/dev/null; then | |
| echo "Error: $1 is not installed" | |
| return 1 | |
| fi | |
| } | |
| check_non_empty_string() { | |
| if [[ -z $1 ]]; then | |
| echo -e "\nError: $2 cannot be empty" | |
| return 1 | |
| fi | |
| } | |
| check_has_installed openssl | |
| read -p "Enter the user password: " identity_password_raw | |
| check_non_empty_string "$identity_password_raw" "user password" | |
| # https://canonical-subiquity.readthedocs-hosted.com/en/latest/reference/autoinstall-reference.html#password | |
| identity_password=$(echo "$identity_password_raw" | openssl passwd -6 -stdin) | |
| echo | |
| read -p "Enter the storage encryption password: " storage_password | |
| check_non_empty_string "$storage_password" "storage encryption password" | |
| # https://canonical-subiquity.readthedocs-hosted.com/en/latest/reference/autoinstall-reference.html | |
| cat >"$AUTOINSTALL_FILE_PATH" <<EOL | |
| autoinstall: | |
| version: 1 | |
| locale: "en_US.UTF-8" | |
| keyboard: | |
| layout: "us" | |
| source: | |
| id: "ubuntu-desktop-minimal" | |
| search_drivers: true | |
| storage: | |
| layout: | |
| name: "lvm" | |
| password: "$storage_password" | |
| identity: | |
| hostname: "$hostname" | |
| realname: "$real_name" | |
| username: "$username" | |
| password: "$identity_password" | |
| codecs: | |
| install: true | |
| drivers: | |
| install: true | |
| oem: | |
| install: "auto" | |
| packages: | |
| - "git" | |
| timezone: "Europe/Berlin" | |
| updates: "all" | |
| shutdown: "reboot" | |
| EOL | |
| echo -e "\nCopy URI for Ubuntu Installer: ${BOLD}file://$AUTOINSTALL_FILE_PATH${RESET}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:24.04 | |
| RUN apt-get update --fix-missing && apt-get install -y sudo=1.9.15* git=1:2.43.0* build-essential=12.10* \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/lists/* | |
| RUN git clone https://github.com/canonical/subiquity.git /app | |
| WORKDIR /app | |
| RUN make install_deps | |
| # Fix 1: systemd and docker don't play well together, let's fake timedatectl command which is used inside the script | |
| RUN mkdir -p /run/systemd/ && touch /run/systemd/system | |
| RUN rm -f /usr/bin/timedatectl | |
| RUN cat > /usr/bin/timedatectl <<EOL | |
| #!/usr/bin/env bash | |
| python3 -c "import pytz; print('\n'.join(pytz.all_timezones))" | |
| EOL | |
| RUN chmod +x /usr/bin/timedatectl | |
| ENTRYPOINT [ "./scripts/validate-autoinstall-user-data.py" ] |
Author
Author
Build docker image
docker build -f Dockerfile -t subiquity .Run the image against a generated autoinstall.yaml:
docker run -v "$PWD":/configs subiquity --no-expect-cloudconfig -vvv /configs/ubuntu-autoinstall.yaml
Author
run auto.sh directly:
eval "$(wget -qO- https://gist.github.com/c0nscience/fefcbfc313b42c2e09ba983c18ac304b/raw/68407fd13e65dade5e4e6a426143b54edd3bef00/auto.sh)"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
forked from
https://github.com/devmatteini/dotfiles/blob/b966eece8d41a2537b0c76610d8f61e701d2f9bd/bootstrap/ubuntu-autoinstall.shcause I am lazy right now to create an etched usb stick with the autoinstall.yaml on it