tazlito view tazlito @ rev 19

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