tazlito view tazlito @ rev 18

pave the road to flavors. Can find packages with 'tazpkg --repack'
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Dec 14 20:40:12 2007 +0000 (2007-12-14)
parents 6bc856bd158d
children bd901a157586
line source
1 #!/bin/sh
2 # TazLito - SliTaz Live Tool.
3 #
4 # Tazlito is a tool to help generating and configuring SliTaz LiveCD
5 # ISO images. You can creat a custom distro in one command from a list of
6 # packages, extract a existing ISO image to hack it, creat new initramfs
7 # and/or new ISO. Most commands must be run by root, expect the stats
8 # and the configuration file manipulation.
9 #
10 # (C) 2007 SliTaz - GNU General Public License.
11 # Initial author : <pankso@slitaz.org>
12 #
13 VERSION=1.2
15 # Tazlito configuration variables to be shorter
16 # and to use words rater than numbers.
17 COMMAND=$1
18 LIST_NAME=$2
19 TMP_DIR=/tmp/tazlito-$$-$RANDOM
20 TOP_DIR=`pwd`
21 INITRAMFS=rootfs.gz
22 LOCALSTATE=/var/lib/tazpkg
23 INSTALLED=$LOCALSTATE/installed
24 CACHE_DIR=/var/cache/tazpkg
25 MIRROR=$LOCALSTATE/mirror
27 # Try to include config file, continue if command is gen-config or exit.
28 # The main config used by default is in /etc/tazlito.
29 if [ -f "/etc/tazlito/tazlito.conf" ] ; then
30 CONFIG_FILE="/etc/tazlito/tazlito.conf"
31 fi
32 # Specific distro config file can be put in a distro tree.
33 if [ -f "$TOP_DIR/tazlito.conf" ] ; then
34 CONFIG_FILE="$TOP_DIR/tazlito.conf"
35 fi
36 if [ ! "$CONFIG_FILE" = "" ] ; then
37 . $CONFIG_FILE
38 else
39 if [ "$COMMAND" = "gen-config" ] ; then
40 continue
41 else
42 echo "Unable to find any configuration file. Please read the doc"
43 echo "or run '`basename $0` gen-config' to get an empty config file."
44 exit 0
45 fi
46 fi
48 # Set the rootfs and rootcd path with $DISTRO
49 # configuration variable.
50 ROOTFS=$DISTRO/rootfs
51 ROOTCD=$DISTRO/rootcd
53 #####################
54 # Tazlito functions #
55 #####################
57 # Print the usage.
58 usage ()
59 {
60 echo -e "\nSliTaz Live Tool - Version: $VERSION\n
61 \033[1mUsage: \033[0m `basename $0` [command] [list|iso] [dir]
62 \033[1mCommands: \033[0m\n
63 usage Print this short usage.
64 stats View Tazlito and distro configuration statistics.
65 gen-config Generate a new configuration file for a distro.
66 configure Configure the main config file or a specific tazlito.conf.
67 gen-iso Generate a new ISO from a distro tree.
68 gen-initiso Generate a new initramfs and ISO from the distro tree.
69 extract-distro Extract and ISO to a directory and rebuild LiveCD tree.
70 gen-distro Generated a Live distro and ISO from a list of packages.
71 clean-distro Remove all files generated by gen-distro.
72 addhacker Add Linux User Hacker to the current distro.
73 check-distro Help to check if distro is ready to release.
74 burn-iso Burn ISO image to a cdrom using Wodim.\n"
75 }
77 # Status function.
78 status()
79 {
80 local CHECK=$?
81 echo -en "\\033[70G[ "
82 if [ $CHECK = 0 ]; then
83 echo -en "\\033[1;33mOK"
84 else
85 echo -en "\\033[1;31mFailed"
86 fi
87 echo -e "\\033[0;39m ]"
88 }
90 yesorno()
91 {
92 echo -n "$1"
93 case "$DEFAULT_ANSWER" in
94 Y|y) answer="y";;
95 N|n) answer="n";;
96 *) read answer;;
97 esac
98 }
100 todomsg()
101 {
102 echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]"
103 }
105 # Download a file trying each mirror
106 download()
107 {
108 for i in $(cat $MIRROR); do
109 wget $i$@
110 done
111 }
113 # exec hooks provided by some packages
114 genisohooks()
115 {
116 local here=`pwd`
117 cd $ROOTFS
118 for i in $(ls etc/tazlito/*.$1 2> /dev/null); do
119 . $i $ROOTCD
120 done
121 cd $here
122 }
124 # echo the package name if the tazpkg is already installed
125 installed_package_name()
126 {
127 local tazpkg
128 local package
129 local VERSION
130 tazpkg=$1
131 # try du find package name and version to be able
132 # to repack it from installation
133 # a dash (-) can exist in name *and* in version
134 package=${tazpkg%-*}
135 i=$package
136 while true; do
137 VERSION=""
138 eval $(grep -s ^VERSION= $INSTALLED/$i/receipt)
139 if [ "$i-$VERSION" = "$tazpkg" ]; then
140 echo $i
141 break
142 fi
143 case "$i" in
144 *-*);;
145 *) break;;
146 esac
147 i=${i%-*}
148 done
149 }
151 # Check if user is root.
152 check_root()
153 {
154 if test $(id -u) != 0 ; then
155 echo -e "\nYou must be root to run `basename $0` with this option."
156 echo -e "Please type 'su' and root password to become super-user.\n"
157 exit 0
158 fi
159 }
161 # Check for the rootfs tree.
162 check_rootfs()
163 {
164 if [ ! -d "$ROOTFS/etc" ] ; then
165 echo -e "\nUnable to find a distro rootfs...\n"
166 exit 0
167 fi
168 }
170 # Check for the boot dir into the root CD tree.
171 verify_rootcd()
172 {
173 if [ ! -d "$ROOTCD/boot" ] ; then
174 echo -e "\nUnable to find the rootcd boot directory...\n"
175 exit 0
176 fi
177 }
179 # Gen a new ISO image using isolinux.
180 gen_livecd_isolinux()
181 {
182 # Some packages may want to alter iso
183 genisohooks iso
184 if [ ! -f "$ROOTCD/boot/isolinux/isolinux.bin" ] ; then
185 echo -e "\nUnable to find isolinux binary.\n"
186 exit 0
187 fi
188 cd $DISTRO
189 echo ""
190 echo -e "\033[1mGenerating ISO image\033[0m"
191 echo "================================================================================"
192 genisoimage -R -o $ISO_NAME.iso -b boot/isolinux/isolinux.bin \
193 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
194 -V "$VOLUM_NAME" -p "$PREPARED" -input-charset iso8859-1 \
195 -boot-info-table $ROOTCD
196 echo "================================================================================"
197 }
199 # Gen a new initramfs from the root file system.
200 gen_initramfs()
201 {
202 # Some packages may want to alter rootfs
203 genisohooks rootfs
204 cd $ROOTFS
205 echo ""
206 # Use lzma if installed
207 if [ -x /usr/bin/lzma ]; then
208 echo -n "Generating lzma'ed initramfs... "
209 find . -print | cpio -o -H newc | lzma e -si -so > $DISTRO/$INITRAMFS
210 else
211 echo -n "Generating gziped initramfs... "
212 find . -print | cpio -o -H newc | gzip -9 > $DISTRO/$INITRAMFS
213 fi
214 cd $DISTRO
215 mv $INITRAMFS $ROOTCD/boot
216 }
218 # Print ISO and rootfs size.
219 distro_stats()
220 {
221 echo ""
222 echo -e "\033[1mDistro statistics\033[0m"
223 echo "================================================================================"
224 echo "Build date : `date +%Y%m%d\ \at\ \%H:%M:%S`"
225 echo "Packages : `ls -1 $ROOTFS/var/lib/tazpkg/installed | wc -l`"
226 echo "Rootfs size : `du -sh $ROOTFS`"
227 echo "Initramfs size : `du -sh $ROOTCD/boot/$INITRAMFS`"
228 echo "ISO image size : `du -sh $ISO_NAME.iso`"
229 echo "================================================================================"
230 echo ""
231 }
233 # Creat an empty configuration file.
234 empty_config_file()
235 {
236 cat >> tazlito.conf << "EOF"
237 # tazlito.conf: Tazlito (SliTaz Live Tool)
238 # configuration file.
239 #
241 # Name of the ISO image to generate.
242 ISO_NAME=""
244 # ISO image volum name.
245 VOLUM_NAME="SliTaz"
247 # Name of the preparator.
248 PREPARED="$USER"
250 # Path to the packages repository and the packages.list.
251 PACKAGES_REPOSITORY=""
253 # Path to the distro tree to gen-distro from a
254 # list of packages.
255 DISTRO=""
257 # Path to the directory contening additional files
258 # to copy into the rootfs and rootcd of the LiveCD.
259 ADDFILES="$DISTRO/addfiles"
261 # Default answer for binary question (Y or N)
262 DEFAULT_ANSWER="ASK"
263 EOF
264 }
266 ####################
267 # Tazlito commands #
268 ####################
270 case "$COMMAND" in
271 stats)
272 # Tazlito general statistics from the config file.
273 #
274 echo ""
275 echo -e "\033[1mTazlito statistics\033[0m
276 ===============================================================================
277 Config file : $CONFIG_FILE
278 ISO name : $ISO_NAME.iso
279 Volum name : $VOLUM_NAME
280 Prepared : $PREPARED
281 Packages repository : $PACKAGES_REPOSITORY
282 Distro directory : $DISTRO"
283 if [ ! "$ADDFILES" = "" ] ; then
284 echo -e "Additional files : $ADDFILES"
285 fi
286 echo "================================================================================"
287 echo ""
288 ;;
289 gen-config)
290 # Gen a new config file in the current dir or the specified
291 # directory by $2.
292 #
293 if [ -n "$2" ] ; then
294 mkdir -p $2 && cd $2
295 fi
296 echo -n "Generating empty tazlito.conf..."
297 empty_config_file
298 status
299 echo ""
300 if [ -f "tazlito.conf" ] ; then
301 echo "Configuration file is ready to edit."
302 echo "File location : `pwd`/tazlito.conf"
303 echo ""
304 fi
305 ;;
306 configure)
307 # Configure a tazlito.conf config file. Start by getting
308 # a empty config file and sed it.
309 #
310 if [ -f "tazlito.conf" ] ; then
311 rm tazlito.conf
312 else
313 if test $(id -u) = 0 ; then
314 cd /etc
315 else
316 echo "You must be root to configure the main config file or in"
317 echo "the same directory of the file you want to configure."
318 exit 0
319 fi
320 fi
321 empty_config_file
322 echo""
323 echo -e "\033[1mConfiguring :\033[0m `pwd`/tazlito.conf"
324 echo "================================================================================"
325 # ISO name.
326 echo -n "ISO name : " ; read answer
327 sed -i s#'ISO_NAME=\"\"'#"ISO_NAME=\"$answer\""# tazlito.conf
328 # Volume name.
329 echo -n "Volume name : " ; read answer
330 sed -i s/'VOLUM_NAME=\"SliTaz\"'/"VOLUM_NAME=\"$answer\""/ tazlito.conf
331 # Packages repository.
332 echo -n "Packages repository : " ; read answer
333 sed -i s#'PACKAGES_REPOSITORY=\"\"'#"PACKAGES_REPOSITORY=\"$answer\""# tazlito.conf
334 # Distro path.
335 echo -n "Distro path : " ; read answer
336 sed -i s#'DISTRO=\"\"'#"DISTRO=\"$answer\""# tazlito.conf
337 echo "================================================================================"
338 echo "Config file is ready to use."
339 echo "You can now extract an ISO or generate a distro."
340 echo ""
341 ;;
342 gen-iso)
343 # Simply generated a new iso.
344 #
345 check_root
346 verify_rootcd
347 gen_livecd_isolinux
348 distro_stats
349 ;;
350 gen-initiso)
351 # Simply generated a new initramfs with a new iso.
352 #
353 check_root
354 verify_rootcd
355 gen_initramfs
356 gen_livecd_isolinux
357 distro_stats
358 ;;
359 extract-distro)
360 # Extract a ISO image to a directory and rebuild the LiveCD tree.
361 #
362 check_root
363 ISO_IMAGE=$2
364 if [ -z "$ISO_IMAGE" ] ; then
365 echo -e "\nPlease specify the path to the ISO image."
366 echo -e "Example : `basename $0` image.iso /path/target\n"
367 exit 0
368 fi
369 # Set the distro path by checking for $3 on cmdline.
370 if [ -n "$3" ] ; then
371 TARGET=$3
372 else
373 TARGET=$DISTRO
374 fi
375 # Exit if existing distro is found.
376 if [ -d "$TARGET/rootfs" ] ; then
377 echo -e "\nA rootfs exist in : $TARGET"
378 echo -e "Please clean the distro tree or change directory path.\n"
379 exit 0
380 fi
381 echo ""
382 echo -e "\033[1mTazlito extracting :\033[0m $ISO_IMAGE"
383 echo "================================================================================"
384 # Start to mount the ISO.
385 echo ""
386 echo "Mounting ISO image..."
387 mkdir -p $TMP_DIR
388 # Get ISO file size.
389 isosize=`du -sh $ISO_IMAGE`
390 mount -o loop $ISO_IMAGE $TMP_DIR
391 sleep 2
392 # Prepare target dir, copy the kernel and the rootfs.
393 mkdir -p $TARGET/rootfs
394 mkdir -p $TARGET/rootcd/boot
395 echo -n "Copying the Linux kernel..."
396 if cp $TMP_DIR/boot/vmlinuz* $TARGET/rootcd/boot 2> /dev/null; then
397 ln $TARGET/rootcd/vmlinuz* $TARGET/rootcd/bzImage
398 else
399 cp $TMP_DIR/boot/bzImage $TARGET/rootcd/boot
400 fi
401 status
402 echo -n "Copying isolinux files..."
403 cp -a $TMP_DIR/boot/isolinux $TARGET/rootcd/boot
404 status
405 echo -n "Copying the rootfs..."
406 cp $TMP_DIR/boot/rootfs.?z $TARGET/rootcd/boot
407 status
408 # Exract initramfs.
409 cd $TARGET/rootfs
410 echo -n "Extracting the rootfs... "
411 ( zcat ../rootcd/boot/rootfs.gz 2>/dev/null || \
412 lzma d ../rootcd/boot/rootfs.?z -so ) | cpio -id
413 # Umount and remove temp directory and cd to $TARGET to get stats.
414 umount $TMP_DIR && rm -rf $TMP_DIR
415 cd ..
416 echo ""
417 echo "================================================================================"
418 echo "Extracted : $ISO_IMAGE ($isosize)"
419 echo "Distro tree : `pwd`"
420 echo "Rootfs size : `du -sh rootfs`"
421 echo "Rootcd size : `du -sh rootcd`"
422 echo "================================================================================"
423 echo ""
424 ;;
425 gen-distro)
426 # Generate a live distro tree with a set of packages.
427 #
428 check_root
429 if [ -d $ROOTFS ] ; then
430 echo "A rootfs exist in : $DISTRO"
431 echo -e "Please clean the distro tree or change directory path.\n"
432 exit 0
433 fi
434 # First check for the main packages list then
435 # for a distro-packages.list in the current directory
436 # if none, check if a package list was specified on cmdline.
437 if [ -f "/etc/slitaz-tools/distro-packages.list" ] ; then
438 LIST_NAME="distro-packages.list"
439 fi
440 if [ -f "distro-packages.list" ] ; then
441 LIST_NAME="distro-packages.list"
442 fi
443 if [ -n "$2" ] ; then
444 if [ ! -f "$2" ] ; then
445 echo -e "\nUnable to find the specified packages list."
446 echo -e "List name : $2\n"
447 exit 0
448 else
449 LIST_NAME=$2
450 fi
451 fi
452 # Exit if no list name.
453 if [ ! -f "$LIST_NAME" ]; then
454 echo -e "\nNo packages list found or specified. Please read the doc.\n"
455 exit 0
456 fi
457 # Start generation.
458 echo ""
459 echo -e "\033[1mTazlito generating a distro\033[0m"
460 echo "================================================================================"
461 # Misc checks
462 [ -n "$PACKAGES_REPOSITORY" ] || PACKAGES_REPOSITORY="."
463 [ -d $PACKAGES_REPOSITORY ] || mkdir -p $PACKAGES_REPOSITORY
464 # Get the list of packages using cat for a file list.
465 LIST=`cat $LIST_NAME`
466 # Verify if all packages in list are presents in $PACKAGES_REPOSITORY.
467 REPACK=""
468 DOWNLOAD=""
469 for pkg in $LIST
470 do
471 pkg=${pkg%.tazpkg}
472 [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] && continue
473 PACKAGE=$(installed_package_name $pkg)
474 [ -n "$PACKAGE" -a "$REPACK" = "y" ] && continue
475 [ -z "$PACKAGE" -a -n "$DOWNLOAD" ] && continue
476 echo -e "\nUnable to find $pkg in the repository."
477 echo -e "Path : $PACKAGES_REPOSITORY\n"
478 if [ -n "$PACKAGE" -a -z "$REPACK" ]; then
479 yesorno "Repack packages from rootfs (y/N) ? "
480 REPACK="$answer"
481 [ "$answer" = "y" ] || REPACK="n"
482 [ "$DOWNLOAD" = "y" ] && break
483 fi
484 if [ -f $MIRROR -a -z "$DOWNLOAD" ]; then
485 yesorno "Download packages from mirror (Y/n) ? "
486 DOWNLOAD="$answer"
487 if [ "$answer" = "n" ]; then
488 [ -z "$PACKAGE" ] && exit 1
489 else
490 DOWNLOAD="y"
491 [ -n "$REPACK" ] && break
492 fi
493 fi
494 [ "$REPACK" = "n" -a "$DOWNLOAD" = "n" ] && exit 1
495 done
496 # Root fs stuff.
497 echo "Preparing the rootfs directory..."
498 mkdir -p $ROOTFS
499 sleep 2
500 for pkg in $LIST
501 do
502 # First copy and extract the package in tmp dir.
503 pkg=${pkg%.tazpkg}
504 PACKAGE=$(installed_package_name $pkg)
505 mkdir -p $TMP_DIR
506 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
507 # look for package in cache
508 if [ -f $CACHE_DIR/$pkg.tazpkg ]; then
509 ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY
510 # look for package in running distribution
511 elif [ -n "$PACKAGE" -a "$REPACK" = "y" ]; then
512 tazpkg repack $PACKAGE && \
513 mv $pkg.tazpkg $PACKAGES_REPOSITORY
514 fi
515 fi
516 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
517 # get package from mirror
518 [ "$DOWNLOAD" = "y" ] && \
519 download $pkg.tazpkg && \
520 mv $pkg.tazpkg $PACKAGES_REPOSITORY
521 fi
522 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
523 echo "Missing package $pkg."
524 exit 1
525 fi
526 yes "" | tazpkg install $PACKAGES_REPOSITORY/$pkg.tazpkg --root=$ROOTFS
527 done
528 echo ""
529 cd $DISTRO
530 # Copy all files from $ADDFILES/rootfs to the rootfs.
531 if [ -d "$ADDFILES/rootfs" ] ; then
532 echo -n "Copying addfiles content to the rootfs... "
533 cp -a $ADDFILES/rootfs/* $ROOTFS
534 status
535 fi
536 echo "Root file system is generated..."
537 # Root CD part.
538 echo -n "Preparing the rootcd directory..."
539 mkdir -p $ROOTCD
540 status
541 # Move the boot dir with the Linux kernel from rootfs.
542 # The boot dir goes directly on the CD.
543 if [ -d "$ROOTFS/boot" ] ; then
544 echo -n "Moving the boot directory..."
545 mv $ROOTFS/boot $ROOTCD
546 cd $ROOTCD/boot
547 ln vmlinuz-* bzImage
548 status
549 fi
550 cd $DISTRO
551 # Copy all files from $ADDFILES/rootcd to the rootcd.
552 if [ -d "$ADDFILES/rootcd" ] ; then
553 echo -n "Copying addfiles content to the rootcd... "
554 cp -a $ADDFILES/rootcd/* $ROOTCD
555 status
556 fi
557 # Initramfs and ISO image stuff.
558 gen_initramfs
559 gen_livecd_isolinux
560 distro_stats
561 ;;
562 clean-distro)
563 # Remove old distro tree.
564 #
565 check_root
566 echo ""
567 echo -e "\033[1mCleaning :\033[0m $DISTRO"
568 echo "================================================================================"
569 if [ -d "$DISTRO" ] ; then
570 if [ -d "$ROOTFS" ] ; then
571 echo -n "Removing the rootfs..."
572 rm -f $DISTRO/$INITRAMFS
573 rm -rf $ROOTFS
574 status
575 fi
576 if [ -d "$ROOTCD" ] ; then
577 echo -n "Removing the rootcd..."
578 rm -rf $ROOTCD
579 status
580 fi
581 echo -n "Removing eventual ISO image..."
582 rm -f $DISTRO/$ISO_NAME.iso
583 status
584 fi
585 echo "================================================================================"
586 echo ""
587 ;;
588 addhacker)
589 # Without /etc/passwd...
590 #
591 check_root
592 echo ""
593 echo -e "\033[1mAdduser hacker to :\033[0m $ROOTFS"
594 echo "================================================================================"
595 if [ ! -d "$ROOTFS/etc" ] ; then
596 echo -e "\nUnable to find : $ROOTFS/etc"
597 echo -e "Users and passwords config files will not be found.\n"
598 exit 0
599 fi
600 # Go for echoing on configuration files if any hacker was found.
601 #
602 if [ ! "`cat $ROOTFS/etc/passwd | grep hacker`" ] ; then
603 echo -n "Configuring $ROOTFS/etc..."
604 echo 'hacker:x:500:500:Linux User,,,:/home/hacker:/bin/ash' >> $ROOTFS/etc/passwd
605 echo 'hacker::13646:0:99999:7:::' >> $ROOTFS/etc/shadow
606 echo 'hacker:x:500:' >> $ROOTFS/etc/group
607 echo 'hacker:!::' >> $ROOTFS/etc/gshadow
608 status
609 else
610 echo "Hacker is already in : $ROOTFS/etc/passwd"
611 fi
612 # Hacker can listen to music
613 #
614 if grep -q audio $ROOTFS/etc/group; then
615 sed -i s/'audio:x:20:'/'audio:x:20:hacker'/ $ROOTFS/etc/group
616 fi
617 # /home/hacker files.
618 #
619 echo -n "Creating default directories... "
620 mkdir -p $ROOTFS/home/hacker/Documents \
621 $ROOTFS/home/hacker/Downloads \
622 $ROOTFS/home/hacker/Images \
623 $ROOTFS/home/hacker/Public \
624 $ROOTFS/home/hacker/Templates
625 status
626 # Change permissions.
627 #
628 echo -n "Chmodig all files in /home/hacker..."
629 chown -R 500.500 $ROOTFS/home/hacker
630 status
631 echo "================================================================================"
632 echo "Linux User Hacker have an account in the distro."
633 echo ""
634 ;;
635 check-distro)
636 # Check for a few LiveCD needed files not installed by packages.
637 #
638 check_rootfs
639 echo ""
640 echo -e "\033[1mChecking distro :\033[0m $ROOTFS"
641 echo "================================================================================"
642 # SliTaz release info.
643 if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
644 echo "Missing release info : /etc/slitaz-release"
645 else
646 release=`cat $ROOTFS/etc/slitaz-release`
647 echo -n "Release : $release"
648 status
649 fi
650 # Tazpkg mirror.
651 if [ ! -f "$ROOTFS/var/lib/tazpkg/mirror" ]; then
652 echo -n "Mirror URL : Missing /var/lib/tazpkg/mirror"
653 todomsg
654 else
655 echo -n "Mirror configuration exist..."
656 status
657 fi
658 # Isolinux msg
659 if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.msg; then
660 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)"
661 todomsg
662 else
663 echo -n "Isolinux message seems good..."
664 status
665 fi
666 echo "================================================================================"
667 echo ""
668 ;;
669 burn-iso)
670 # Guess cdrom device, ask user and burn the ISO.
671 #
672 check_root
673 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
674 DRIVE_SPEED=`cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3`
675 # We can specify an alternative ISO from the cmdline.
676 if [ -n "$2" ] ; then
677 iso=$2
678 else
679 iso=$DISTRO/$ISO_NAME.iso
680 fi
681 if [ ! -f "$iso" ]; then
682 echo -e "\nUnable to find ISO : $iso\n"
683 exit 0
684 fi
685 echo ""
686 echo -e "\033[1mTazlito burn ISO\033[0m "
687 echo "================================================================================"
688 echo "Cdrom device : /dev/$DRIVE_NAME"
689 echo "Drive speed : $DRIVE_SPEED"
690 echo "ISO image : $iso"
691 echo "================================================================================"
692 echo ""
693 yesorno "Burn ISO image (y/N) ? "
694 if [ "$answer" == "y" ]; then
695 echo ""
696 echo "Starting Wodim to burn the iso..." && sleep 2
697 echo "================================================================================"
698 wodim speed=$DRIVE_SPEED dev=/dev/$DRIVE_NAME $DISTRO/$ISO_NAME.iso
699 echo "================================================================================"
700 echo "ISO image is burned to cdrom."
701 else
702 echo -e "\nExiting. No ISO burned."
703 fi
704 echo ""
705 ;;
706 usage|*)
707 # Clear and print usage also for all unknow commands.
708 #
709 clear
710 usage
711 ;;
713 esac
715 exit 0