#!/bin/bash # create-gfxboot.bash # (C) by Andreas Loibl (acritox) # Licence: GPL function debug() { [ "$DEBUG" ] || return 0; echo -e "$@" >&2 } function exitWithProblem() { echo "$(basename $0) - ERROR: $@" >&2 exit 1 } # check for some directories and files [ -d "./source" ] || exitWithProblem 'directory "./source" missing!' [ -d "./iso" ] || exitWithProblem 'directory "./iso" missing!' [ -d "./iso/boot" ] || exitWithProblem 'directory "./iso/boot" missing!' [ -d "./iso/boot/grub" ] || exitWithProblem 'directory "./iso/boot/grub" missing!' sourcedir="$(find ./source/ -name kanotix-graphics* -type d)" [ -d "$sourcedir" ] || exitWithProblem "sourcedir (./source/kanotix-graphics*/) missing!" debug "found sourcedir: $sourcedir" gfxbootdir="$sourcedir/gfxboot-theme" [ -d "$gfxbootdir" ] || exitWithProblem "gfxboot-theme ($gfxbootdir) missing!" debug "found gfxbootdir: $gfxbootdir" # main part: functions function doCleanUp() { debug "cleaning up in $1 ..." make -C "$1" clean >/dev/null debug "cleaning up in ./iso/boot/grub ..." rm "./iso/boot/grub/message" 2>/dev/null && echo "removed ./iso/boot/grub/message" debug "cleaning up in ./" rm "./message" 2>/dev/null && echo "removed ./message" rm "./gfxboot.iso" 2>/dev/null && echo "removed ./gfxboot.iso" debug "cleaning up finished." } function doMake() { debug "making message-file in $1 ..." make -C "$1" || exitWithProblem "make failed!" } function doMoveToISO() { debug "moving message-file to ./iso/boot/grub/ ..." rm -f ./iso/boot/grub/message mv "$1" ./iso/boot/grub/message || exitWithProblem "doMoveToISO failed!" } function doCreateISO() { mkisofs -input-charset ISO-8859-15 -pad -l -r -J \ -V 'GRUBTEST' -A 'TEST LIVECD WITH KANOTIX GRUB' \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -b boot/grub/iso9660_stage1_5 -c boot/grub/boot.cat \ -hide-rr-moved \ -o "$1" ./iso || exitWithProblem "mkisofs failed!" } function createISO() { doCleanUp "$gfxbootdir" # check if a background.pcx is there and "make" if it is true [ -e "$gfxbootdir/background.pcx" ] && doMake "$gfxbootdir" || ( debug "file not found: $gfxbootdir/background.pcx"; echo "=> not starting \"make\"" ) # check if a message-file is there and move it to the iso [ -e "$gfxbootdir/boot/message" ] && doMoveToISO "$gfxbootdir/boot/message" || ( debug "file not found: $gfxbootdir/boot/message"; echo "=> not moving message-file to iso" ) # check if a message-file is in ./iso/boot/grub/ and create iso-file [ -e "./iso/boot/grub/message" ] && doCreateISO "gfxboot.iso" || ( debug "file not found: ./iso/boot/grub/message"; echo "=> not creating iso-file" ) # success message [ -e "./gfxboot.iso" ] && echo && echo "*** ./gfxboot.iso has been created successfully." } function createMessage() { doCleanUp "$gfxbootdir" # check if a background.pcx is there and "make" if it is true [ -e "$gfxbootdir/background.pcx" ] && doMake "$gfxbootdir" || ( debug "file not found: $gfxbootdir/background.pcx"; echo "=> not starting \"make\"" ) # check if a message-file is there and move it to the iso [ -e "$gfxbootdir/boot/message" ] && mv "$gfxbootdir/boot/message" ./ || ( debug "file not found: $gfxbootdir/boot/message"; echo "=> not moving message-file to ./" ) # success message [ -e "./message" ] && echo && echo "*** ./message has been created successfully." } case $1 in clean|cleanup) doCleanUp "$gfxbootdir" ;; message) createMessage ;; iso) createISO ;; both) createISO && cp ./iso/boot/grub/message ./ && echo "*** ./message has been created successfully." ;; *) echo "Usage: $(basename $0) cleanup: cleans everything. Only sources will be left. message: creates a message file only (target: ./message) iso: creates a iso file (target: ./gfxboot.iso) both: creates a iso and a message file Run with DEBUG=1 $(basename $0) and you'll get a more verbose output. This script is written by Andreas Loibl (acritox) Email: Web: http://www.andreas-loibl.de " ;; esac echo echo "=> $(basename $0) finished." exit 0