Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automate the Ignition password setting step from https://en.opensuse.org/Portal:MicroOS/Ignition
#!/bin/sh
# Automate the password setting step from
# https://en.opensuse.org/Portal:MicroOS/Ignition
#
# 1. Ask for a password interactively.
# 2. Make an ignition.iso for setting root's password to that.
# An existing ignition.iso will be overwritten.
#
# Required commands
# openssl
# mkisofs
# sudo zypper install mkisofs openssl
set -eu
IGNDIR=$(mktemp --directory ignition.XXXXXX)
mkdir -p "$IGNDIR"/ignition
CONFIG="$IGNDIR"/ignition/config.ign
cat > "$CONFIG" <<EOF
{
"ignition": { "version": "3.1.0" },
"passwd": {
"users": [
{
"name": "root",
"passwordHash": "@PASSWORDHASH@"
}
]
}
}
EOF
echo >&2 "Choose a password. I will write ignition.iso with that password for root."
PASSWORDHASH="$(openssl passwd -6)"
sed -i -e "s:@PASSWORDHASH@:$PASSWORDHASH:" "$CONFIG"
mkisofs -o ignition.iso -V ignition -quiet "$IGNDIR"
rm -rf "$IGNDIR"
echo >&2 Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment