2 # Project page: http://www.sysresccd.org/
4 # (C) 2003-2007 Francois Dupoux
5 # This scipt is available under the GPL-2 license.
7 ## HELP AND BASIC ARGUMENT PROCESSING
8 #####################################
13 sysresccd-custom: SystemRescueCd customization script for SPARC
14 Syntax: sysresccd-custom <command> ...
16 Please, read the manual for help about how to use this script.
17 http://www.sysresccd.org/Sysresccd-manual-en_How_to_personalize_SystemRescueCd
19 Commands (execute in that order):
20 1) extract Extract files from the squashfs into your hard disk
21 2) squashfs Create the new compressed loopback squashfs filesystem
22 3) setkmap <keymap-code> Force a keymap to be loaded without prompt at startup
23 4) isogen <cd_volume_name> Generate the final bootable ISO image
25 -h|--help Display this screen
27 Copyright 2003-2007 Francois Dupoux. (http://www.sysresccd.org)
28 Distributed under the GNU Public License version 2
32 ## MISC FUNCTIONS: Many utilities functions
33 ###########################################
35 # show the error message ($1 = first line of the message)
39 echo "Please, read the manual for more help about this script"
40 echo "Web: http://www.sysresccd.org"
45 ###########################################
47 if [ "$1" = "-h" ] || [ "$1" = "--help" ]
53 if [ "`whoami`" != "root" ]
55 help_readman "$0: This script requires root privileges to operate."
59 if [ ! -d "/mnt/custom" ]
61 help_readman "$0: You need to mount a partition with free space on /mnt/custom"
65 cat /proc/mounts | grep " /mnt/custom " > /dev/null
67 echo "/mnt/custom is mounted -> ok"
69 help_readman "$0: /mnt/custom is not mounted. Cannot continue."
78 #####################################
84 echo "${PROG}: error: $1"
86 echo "${PROG}: aborting."
95 echo "do_extract: error: $1"
97 echo "do_extract: aborting."
104 #umount /mnt/custom/customcd/cloop/files/
107 echo "do_squashfs: error: $1"
109 echo "do_squashfs: aborting."
118 echo "do_isogen: error: $1"
120 echo "do_isogen: aborting."
129 echo "do_setkmap: error: $1"
131 echo "do_setkmap: aborting."
136 ## MISC FUNCTIONS: Many utilities functions
137 ###########################################
139 # $1 == MB required by the function
142 SIZE=`(\df -m -P) | grep " /mnt/custom$" | tail -n 1 | awk '{print $4}'`
144 if [ $SIZE -gt $1 ]; then
145 echo "there is enough estimated free space here ($SIZE MB) -> ok"
147 echo "$PROG: not enough room in /mnt/custom"
148 help_readman "You only have $SIZE MB free, and the script needs at least $1 MB free"
153 # check the original SystemRescueCd disc is mounted
154 check_origcdmounted()
156 grep docache /proc/cmdline > /dev/null
157 if [ $? -eq 1 ]; then
158 echo "docache not used -> ok"
161 CMDLINE="`cat /proc/cmdline`"
164 if [ "$x" = "docache" ]
167 cat /proc/mounts | grep " /mnt/cdrom " > /dev/null
168 if [ $? -eq 1 ]; then
172 if [ $docache_error -eq 0 ]; then
173 if [ ! -f /mnt/cdrom/sysrcd.dat ]; then
176 if [ ! -d /mnt/cdrom/boot ]; then
179 if [ ! -f /mnt/cdrom/boot/silo.conf ]; then
184 if [ $docache_error -eq 1 ]; then
185 echo "$0: When using docache option you must mount the "
186 help_readman "original version of SystemRescueCd."
189 echo "docache used and original /mnt/cdrom is mounted -> ok"
196 ## MAIN FUNCTIONS: Extracting the squashfs to the hard disk
197 ########################################################
200 # check for free space
206 # check the original cd is mounted
209 # copy the boot files
210 mkdir -p /mnt/custom/customcd/isoroot/
211 rm -rf /mnt/custom/customcd/isoroot/*
212 cp -a /mnt/cdrom/boot /mnt/custom/customcd/isoroot/ || extract_die
215 mkdir -p /mnt/custom/customcd/files/
216 rm -rf /mnt/custom/customcd/files/*
217 cp -dpR /mnt/livecd/* /mnt/custom/customcd/files/ || extract_die
220 ## MAIN FUNCTIONS: Create the new squashfs image from files
221 ########################################################
224 # check for free space
227 mkdir -p /mnt/custom/customcd/
228 mkdir -p /mnt/custom/customcd/files/
229 mkdir -p /mnt/custom/customcd/isoroot/
230 touch "/mnt/custom/customcd/files/customized"
232 mksquashfs /mnt/custom/customcd/files/ /mnt/custom/customcd/isoroot/sysrcd.dat || squashfs_die
233 (cd /mnt/custom/customcd/isoroot/ ; md5sum sysrcd.dat > sysrcd.md5)
235 # Change permissions to allow the file to be sent by thttpd for PXE-boot
236 chmod 666 /mnt/custom/customcd/isoroot/sysrcd.dat
237 chmod 666 /mnt/custom/customcd/isoroot/sysrcd.md5
240 ## MAIN FUNCTIONS: Force a keymap to be loaded without prompt
241 ########################################################
244 if [ "$KEYMAP" = "" ]
250 if [ ! -d "/mnt/custom/customcd/isoroot/boot" ]
252 help_readman "$PROG: You have to run command prepiso before setkmap"
256 echo "Keymap to be loaded: ${KEYMAP}"
258 # Set keymap in silo.conf
259 cp /mnt/custom/customcd/isoroot/boot/silo.conf /mnt/custom/customcd/isoroot/boot/silo.bak
260 sed -e "s:append:append setkmap=${KEYMAP}:g" /mnt/custom/customcd/isoroot/boot/silo.bak > /mnt/custom/customcd/isoroot/boot/silo.conf
263 ## MAIN FUNCTIONS: Create the new ISO image
264 ########################################################
267 # check for free space
270 if [ "$ISO_VOLUME" = "" ]
276 mkdir -p /mnt/custom/customcd/isofile/
277 rm -rf /mnt/custom/customcd/isofile/*
279 if [ ! -d "/mnt/custom/customcd/isoroot/boot" ]
281 help_readman "$PROG: You have to run command squashfs before isogen"
285 touch "/mnt/custom/customcd/isoroot/customized"
287 echo "Volume name of the CDRom: ${ISO_VOLUME}"
289 mkisofs -G /boot/isofs.b -J -V "${ISO_VOLUME}" -B ... -r \
290 -o /mnt/custom/customcd/isofile/sysresccd-new.iso \
291 /mnt/custom/customcd/isoroot || isogen_die
293 md5sum /mnt/custom/customcd/isofile/sysresccd-new.iso > /mnt/custom/customcd/isofile/sysresccd-new.md5
295 echo "Final ISO image: /mnt/custom/customcd/isofile/sysresccd-new.iso"
299 ## MAIN SHELL FUNCTION
300 ########################################################