Skip to content

Instantly share code, notes, and snippets.

@psi-4ward
Last active December 2, 2023 06:41
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save psi-4ward/4121143240ef9e4746a6 to your computer and use it in GitHub Desktop.
Save psi-4ward/4121143240ef9e4746a6 to your computer and use it in GitHub Desktop.
Customize Grml LiveCD (remaster)

Customize Grml LiveCD (remaster)

This little bash script helps you to build your own customized grml.iso

Features

  • Include your .ssh/*.pub files into authorized_keys
  • Inject Grml Cheats
  • Auto download all necessary files (the ISO and grml2usb)

Defaults

  • grml96-full_2014.11.iso
  • Cheats
    • ssh=grml Start SSH Server and set the root password to grml
    • lang=de keyboard=de German
    • nobeep Suppress beep sound on boot
    • noblank Disable screen energy saving
    • noquick Disable GRML config tool
    • startup=/usr/bin/ip-screen Show IP-Addresses after boot

Usage example

./make-customized-grml.sh [grml.iso file] "[GRML Cheats]"
./make-customized-grml.sh grml64-small_2014.11.iso "ssh=secretPassword noblank welcome"

PS: Dont forget the to warp the GRML-Cheats with quotes.

#!/usr/bin/env bash
# The iso file to use as source (gets downloaded if doesnt exists)
ISO=$1
[ "$ISO" = "" ] && ISO="grml96-full_2014.11.iso"
# List of GRML cheat codes to inject
# see http://git.grml.org/?p=grml-live.git;a=blob_plain;f=templates/GRML/grml-cheatcodes.txt;hb=HEAD
GRMLCODES=$2
[ "$GRMLCODES" = "" ] && GRMLCODES="ssh=grml lang=de keyboard=de nobeep noblank noquick startup=/usr/bin/ip-screen"
USER=`whoami`
TMPDIR="./grml_tmp"
OVERLAYDIR="./grml_overlay"
OUTFILE=`echo $ISO | sed -e 's/.iso$/-customized.iso/'`
function errorAndExit {
echo ERROR: $1
exit 1
}
if [ ! -d "grml2usb" ] ; then
echo Downloading grml2usb
mkdir grml2usb
cd grml2usb
curl -s http://grml.org/grml2usb/grml2usb.tgz | tar --strip 1 -xz \
|| errorAndExit "Could not download grml2usb from http://grml.org/grml2usb/grml2usb.tgz"
cd ..
# Patch grml2usb to use python2
[ ! which python &>/dev/null ] && errorAndExit "python executable not found! I need version 2"
PYTHONVER2=`python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'`
if [ "$PYTHONVER2" != "1" ]; then
[ ! which python2 &>/dev/null] && errorAndExit "python version is > 2 and i didnt find python2 executable"
sed -i '1 s/.*/#!\/usr\/bin\/env python2/g' grml2usb/grml2usb
fi
fi
if [ ! -f "$ISO" ] ; then
echo Downloading $ISO
wget -q --show-progress http://download.grml.org/$ISO \
|| errorAndExit "Could not download $ISO"
fi
[ -d $TMPDIR ] || mkdir -p $TMPDIR
[ -d $OVERLAYDIR ] || mkdir -p $OVERLAYDIR
echo Including public SSH keys into authorized_keys
mkdir -p $TMPDIR/root/.ssh $TMPDIR/home/grml/.ssh
chmod 0700 $TMPDIR/root/.ssh $TMPDIR/home/grml/.ssh
cat /home/$USER/.ssh/*.pub > $TMPDIR/root/.ssh/authorized_keys
cat /home/$USER/.ssh/*.pub > $TMPDIR/home/grml/.ssh/authorized_keys
sudo chown -R 1000:1000 $TMPDIR/home/grml || exit 1
echo Generating overlay
tar --numeric-owner -j -c -f $OVERLAYDIR/config.tbz $TMPDIR || exit 1
echo Generating $OUTFILE
[ -f "OUTFILE" ] && rm $OUTFILE
sudo python=python2 GRML2USB=grml2usb/grml2usb grml2usb/grml2iso -b "$GRMLCODES" -c $OVERLAYDIR -o $OUTFILE $ISO
sudo chown $USER $OUTFILE
echo Cleanup
rm -rf $OVERLAYDIR $TMPDIR
echo
echo DONE
echo Your new ISO is $OUTFILE
echo I injected your pubkey and following GRML cheats: $GRMLCODES
@Razikus
Copy link

Razikus commented Feb 6, 2018

Hey, add "config" for GRMLCODES by default please - it's needed to autoconfigure grml in newest versions.

@mafrosis
Copy link

mafrosis commented Nov 9, 2018

This is awesome. Thank you @psi-4ward

@blurayne
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment