Created
June 9, 2021 07:44
-
-
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
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
#!/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