Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created June 9, 2021 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvidner/ad5e21a493cfffde437a968df4ce79d3 to your computer and use it in GitHub Desktop.
Save mvidner/ad5e21a493cfffde437a968df4ce79d3 to your computer and use it in GitHub Desktop.
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