| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
if [ $ |
|---|
| 11 |
if [ -e "$1" ]; then |
|---|
| 12 |
echo "File already exists, please choose a different destination" |
|---|
| 13 |
exit 1 |
|---|
| 14 |
fi |
|---|
| 15 |
if [ "$1" -eq "-h" -o $1 -eq "--help" ]; then |
|---|
| 16 |
echo "Builds a mainmodule from your current install" |
|---|
| 17 |
echo "Note that you need enough freespace and RAM" |
|---|
| 18 |
echo " Usage: install2mainmod [/tmp/destination.mod]" |
|---|
| 19 |
exit 1 |
|---|
| 20 |
fi |
|---|
| 21 |
fi |
|---|
| 22 |
|
|---|
| 23 |
if [ -n "$1" ]; then |
|---|
| 24 |
DESTMOD=$1 |
|---|
| 25 |
else |
|---|
| 26 |
DESTMOD="/tmp/MorphixMain-generated.mod" |
|---|
| 27 |
fi |
|---|
| 28 |
|
|---|
| 29 |
echo "Ready to start mainmodule generating from current installed Linux" |
|---|
| 30 |
echo "Press enter to continue, Ctrl-C to abort" |
|---|
| 31 |
read |
|---|
| 32 |
echo |
|---|
| 33 |
echo "Copying files, please wait..." |
|---|
| 34 |
|
|---|
| 35 |
MODDIR=`mktemp -d i2m.XXXXXX` |
|---|
| 36 |
|
|---|
| 37 |
if [ -z "$MODDIR" ]; then |
|---|
| 38 |
echo "MODDIR not set, aborting to avoid chaos..." |
|---|
| 39 |
exit 1 |
|---|
| 40 |
fi |
|---|
| 41 |
|
|---|
| 42 |
if [ "$MODDIR" -eq "" ]; then |
|---|
| 43 |
echo "MODDIR is equal to empty string, aborting to avoid chaos..." |
|---|
| 44 |
exit 1 |
|---|
| 45 |
fi |
|---|
| 46 |
|
|---|
| 47 |
mkdir $MODDIR/MorphixCD |
|---|
| 48 |
mkdir $MODDIR/boot |
|---|
| 49 |
mkdir $MODDIR/cdrom |
|---|
| 50 |
mkdir $MODDIR/cdrom1 |
|---|
| 51 |
mkdir $MODDIR/dev |
|---|
| 52 |
mkdir $MODDIR/floppy |
|---|
| 53 |
mkdir $MODDIR/home |
|---|
| 54 |
mkdir $MODDIR/mnt |
|---|
| 55 |
mkdir $MODDIR/proc |
|---|
| 56 |
mkdir $MODDIR/root |
|---|
| 57 |
mkdir $MODDIR/tmp |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
if [ -e /morphix ]; then |
|---|
| 63 |
cp -af /morphix $MODDIR/ |
|---|
| 64 |
else |
|---|
| 65 |
NOMORPHDIR=yes |
|---|
| 66 |
mkdir $MODDIR/morphix |
|---|
| 67 |
echo "#!/bin/sh" >> $MODDIR/morphix/loadmod.sh |
|---|
| 68 |
echo "echo \"Chrooting to MainModule\"" >> $MODDIR/morphix/loadmod.sh |
|---|
| 69 |
echo "chroot /mnt/main sh /morphix/init.sh" >> $MODDIR/morphix/loadmod.sh |
|---|
| 70 |
echo "#!/bin/sh" >> $MODDIR/morphix/init.sh |
|---|
| 71 |
echo "# Put stuff to load at boottime here" >> $MODDIR/morphix/init.sh |
|---|
| 72 |
echo "MyLivecd" >> $MODDIR/morphix/main_module |
|---|
| 73 |
echo "This mainmodule has been auto-generated by install2mainmod" >> $MODDIR/morphix/main_module |
|---|
| 74 |
fi |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
cp -af /bin $MODDIR/ |
|---|
| 78 |
cp -af /etc $MODDIR/ |
|---|
| 79 |
cp -af /lib $MODDIR/ |
|---|
| 80 |
|
|---|
| 81 |
rm -rf $MODDIR/lib/modules/* |
|---|
| 82 |
cp -af /sbin $MODDIR/ |
|---|
| 83 |
cp -af /usr $MODDIR/ |
|---|
| 84 |
cp -af /var $MODDIR/ |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
mkdir $MODDIR/usr/lib/backup |
|---|
| 89 |
mv $MODDIR/usr/lib/libGL.* $MODDIR/usr/lib/backup |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
chroot $MODDIR deluser --remove-all-files morph |
|---|
| 94 |
|
|---|
| 95 |
echo "Done creating the uncompressed livecd in $MODDIR" |
|---|
| 96 |
echo "You now have the possibility to make manual changes" |
|---|
| 97 |
if [ -n "$NOMORPHDIR" ]; then |
|---|
| 98 |
echo "As your system didn't have a /morphix directory, I made one for you" |
|---|
| 99 |
echo "However, you'll have to manually edit the $MODDIR/morphix/init.sh script" |
|---|
| 100 |
echo "in order for anything to load at boottime." |
|---|
| 101 |
echo "See our CVS/scripts-main and www.morphix.org for examples" |
|---|
| 102 |
fi |
|---|
| 103 |
echo "Press enter to continue and compress the filesystem, press Ctrl-C to abort" |
|---|
| 104 |
read |
|---|
| 105 |
|
|---|
| 106 |
`mkisofs -R -U -V "Morphix" -P "Morphix" -hide-rr-moved -cache-inodes -no-bak -pad $MODDIR | nice -5 create_compressed_fs - 65536 > $DESTMOD` |
|---|
| 107 |
|
|---|
| 108 |
echo |
|---|
| 109 |
echo "Compressing complete" |
|---|
| 110 |
echo "Your module is available as $DESTMOD" |
|---|
| 111 |
echo "Your uncompressed module is available as $MODDIR, you may safely remove it" |
|---|
| 112 |
echo "Have a nice day, and happy morphing!" |
|---|
| 113 |
echo |
|---|