MultiCD - How Plugins Work
Last updated: Feb. 10, 2012
Each plugin has its own file in the plugins folder. I'll take austrumi.sh, the plugin for Austrumi Linux, as an example.
#!/bin/sh
set -e
. "${MCDDIR}"/functions.sh
#Austrumi plugin for multicd.sh
#version 6.9
#Copyright (c) 2010 Isaac Schemm
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
This section contains the "set -e" command that tells the script to quit on errors, the name and version of the plugin, and the MIT license. It also has a command . ${MCDDIR}/functions.sh, which loads the functions mcdmount and umcdmount from the functions.sh file packaged with multicd.sh. The variable ${MCDDIR} is set by multicd.sh - it's the folder multicd is in.
if [ $1 = scan ];then if [ -f austrumi.iso ];then echo "Austrumi" fi
multicd.sh calls this section near the beginning of the script.
Each plugin will scan to see if its respective ISO is in the folder and should be included.
For some plugins, it might be more complicated, i.e. if two CDs can't be on the same disc.
elif [ $1 = copy ];then
if [ -f austrumi.iso ];then
mcdmount austrumi
cp -r "${MNT}"/austrumi/austrumi "${WORK}"/ #This folder also has the kernel and initrd
cp "${MNT}"/austrumi/isolinux.cfg "${WORK}"/boot/isolinux/al.menu
umcdmount austrumi
fi
This is the copy section, called in the middle of multicd.sh.
First, the plugin sees if the ISO is there (again, since it doesn't remember), then the
mcdmount function makes a temporary mountpoint for the ISO image, makes sure
nothing's mounted there, then mounts it.
After mounting, the necessary components are copied into multicd's working directory.
For Austrumi, they're all in one folder. Once this is done, umcdmount unmounts
and removes the mountpoint.
NOTE: $MNT and $WORK are defined in multicd.sh; $MNT is a location (in /tmp) where
temporary mountpoints are made, and $WORK is the folder containg the future contents
of the ISO (normally set to $(pwd)/multicd-working).
Each ISO will have different files that need to be copied.
This will often be a kernel, an initrd, and a file or folder with a compressed
filesystem image (like Ubuntu's casper.)
elif [ $1 = writecfg ];then
if [ -f austrumi.iso ];then
echo "label austrumilinux
menu label ^Austrumi
com32 vesamenu.c32
append al.menu
" >> "${WORK}"/boot/isolinux/isolinux.cfg
fi
The third part of the plugin script is called right before the multicd.iso image is made.
This section adds the distro's ISOLINUX commands to the new isolinux.cfg.
It checks if the ISO is there (yet again,) and if it is, it appends text to isolinux.cfg.
In Austrumi's case, the menu option simply loads the submenu, which is the isolinux.cfg
that was copied over from the original ISO. (menu.c32 and vesamenu.c32 are both put in
/boot/isolinux automatically by the script.) Usually, you will see either a longer list of
commands or the above plus some sed commands to modify the contents of the copied
submenu (often necessary if the distro is in a different folder.) The decision on which
direction to go (hardcoding options vs. copying and editing)
depends on how many options the distro has and how often it gets updated.
If you choose to hardcode the options (which is easier), check the isolinux.cfg of the
original ISO to see what to put here.
Keep in mind that if the files aren't in the same place as they are on the original CD,
you'll have to change some things (i.e. for Feather Linux, this might be using
"/boot/feather" instead of "/boot/isolinux" and adding "knoppix_dir=FEATHER".)
else
echo "Usage: $0 {scan|copy|writecfg}"
echo "Use only from within multicd.sh or a compatible script!"
echo "Don't use this plugin script on its own!"
fi
The end is always the same. If the script is not called with one of the three arguments multicd.sh uses (i.e. if a user calls it seperately), the script tells the user that the script can't be used on its own.