2 # Filename: grml-live-remaster
3 # Purpose: remaster a grml from the live cd
4 # Authors: grml-team (grml.org), (c) Michael Schierl <schierlm@gmx.de>, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
9 # this script currently lacks LOTS of error checking code... any help welcome...
10 ################################################################################
12 set -e # exit on any error
16 # source core functions {{{
17 . /etc/grml/lsb-functions
18 . /etc/grml/script-functions
21 # make sure we have what we need {{{
22 check4progs mkisofs mksquashfs || exit 1
26 if [ x"$1" == x ]; then
27 echo "$0 - version $VERSION"
29 echo "Usage: $0 destination.iso"
30 echo " destination.iso should point to a path that is on a hard disk,"
31 echo " you might want to mount some swap partitions or swap files"
32 echo " first, because grml-live-remaster will need a lot ot RAM."
34 echo "Please report bugs and feature requests: http://grml.org/bugs/"
38 if [ ! -d /remaster ]; then
39 mkdir -p /remaster/chroot /remaster/tmp /remaster/cdrom
40 mount -t tmpfs tmpfs /remaster/tmp
41 echo "#:# edit the following two lines to change the boot message" \
43 echo "#:#" >>/remaster/msg
44 if [ -r /live/image/boot/isolinux/boot.msg ] ; then
45 sed 1,2d /live/image/boot/isolinux/boot.msg >>/remaster/msg
47 sed 1,2d /live/image/boot.msg >>/remaster/msg
51 SQUASHFS_FILE="$(find /live/image/live -name \*.squashfs | head -1)"
52 if ! grep -q "/remaster/cdrom squashfs" /proc/mounts ; then
53 mount -t squashfs "$SQUASHFS_FILE" /remaster/cdrom -o ro,loop
56 if ! grep -q "aufs /remaster/chroot" /proc/mounts ; then
57 mount -t aufs aufs /remaster/chroot -o br:/remaster/tmp=rw:/remaster/cdrom=rr
60 for i in dev proc root sys tmp; do
61 mount --bind /$i /remaster/chroot/$i
64 echo "Now edit the contents of the live CD in this chrooted shell:"
65 chroot /remaster/chroot
67 for i in dev proc root sys tmp; do
68 umount /remaster/chroot/$i
73 [ -d /remaster/iso ] || mkdir /remaster/iso
75 for i in /live/image/*; do
76 if [ ! $i == /live/image/live ]; then
77 cp -R $i /remaster/iso
81 if [ -r /remaster/iso/boot/isolinux/boot.msg ] ; then
82 rm /remaster/iso/boot/isolinux/boot.msg
85 # make sure we support usb sticks as well:
86 if [ -d /live/image/boot/isolinux ] ; then
87 BOOTSTUFF=/live/image/boot/isolinux
92 [ -d /remaster/iso/boot/isolinux ] || mkdir -p /remaster/iso/boot/isolinux
94 sed 3,4d "${BOOTSTUFF}"/boot.msg \
95 >/remaster/iso/boot/isolinux/boot.msg
96 sed 1,2d /remaster/msg >>/remaster/iso/boot/isolinux/boot.msg
98 mkdir /remaster/iso/live
99 mksquashfs /remaster/chroot /remaster/iso/live/"$(basename $SQUASHFS_FILE)"
100 umount /remaster/chroot /remaster/cdrom
102 if [ -f /remaster/iso/boot/isolinux/isolinux.bin ] ; then
103 ISOLINUX=boot/isolinux/isolinux.bin
104 ISOLINUX_BOOTCAT=boot/isolinux/boot.cat
106 ISOLINUX=isolinux.bin
107 ISOLINUX_BOOTCAT=boot.cat
110 mkisofs -b $ISOLINUX -no-emul-boot -c $ISOLINUX_BOOTCAT \
111 -boot-info-table -l -r -J -o "$1" /remaster/iso
115 echo "ISO generation complete:"
117 echo "If you want to customize your ISO, just call grml-live-remaster again."
119 ## END OF FILE #################################################################
120 # vim: ai filetype=sh expandtab