|
#!/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 |
Please have also a look at https://gitlab.com/blurayne/grml-iso-remaster