slitaz-tools view tinyutils/frugal @ rev 945

Add Name[fr] in .desktop
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jul 12 17:58:23 2015 +0200 (2015-07-12)
parents 5d80f6fdbdb7
children
line source
1 #!/bin/sh
2 #
3 # Frugal is a tiny tool to handle SliTaz frugal installation.
4 #
5 # Copyright (C) 2013-2015 SliTaz GNU/Linux - BSD License
6 #
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 . /lib/libtaz.sh
12 [ "$root" ] || root="/boot/frugal"
15 # NOTES:
16 # Have a --web option to dl ISO ?
17 # Auto configure GRUB ?
18 #
21 # Internationalization
23 export TEXTDOMAIN='slitaz-tools'
26 #
27 # Functions
28 #
31 # Small help and usage.
33 usage() {
34 name=$(basename $0)
35 cat << EOT
37 $(boldify $(_n 'Usage:')) $name [iso|command] [--options]
39 $(_n 'SliTaz frugal installation')
41 $(boldify $(_n 'Commands:'))
42 info $(_n 'Display install path and size stats')
43 clean $(_n 'Remove all frugal files')
44 grub-ex $(_n 'Show GRUB configuration example')
46 $(boldify $(_n 'Options:'))
47 --root= $(_n 'Set root installation path')
48 --debug $(_n 'Display some useful debug information')
50 $(boldify $(_n 'Examples:'))
51 $name slitaz-rolling.iso
52 $name slitaz-5.0.iso --root=/boot/frugal
54 EOT
55 }
58 # GRUB config example.
60 grub_example() {
61 cat <<EOT
62 title SliTaz GNU/Linux (frugal)
63 root (hd0,0)
64 kernel /boot/frugal/bzImage root=/dev/null lang=en kmap=us
65 initrd /boot/frugal/rootfs.gz
66 EOT
67 }
70 #
71 # Commands
72 #
74 case "$1" in
75 "") usage ;;
76 info)
77 title 'Frugal info'
79 # First check if we are running in frugal mode
80 if fgrep -q 'root=/dev/null' /proc/cmdline; then
81 _ 'Frugal system running detected'
82 footer; exit 0
83 fi
84 _n 'Installation directory:'; indent 30 $(colorize 36 "$root")
85 _n 'Kernel size:'
86 if [ -f "${root}/bzImage" ]; then
87 indent 30 $(du -sh ${root}/bzImage | awk '{print $1}')
88 else
89 indent 30 $(boldify 'N/A')
90 fi
91 _n 'Rootfs size:'
92 if [ -f "${root}/rootfs.gz" ]; then
93 indent 30 $(du -sh ${root}/rootfs.gz | awk '{print $1}')
94 else
95 indent 30 $(boldify 'N/A')
96 fi
97 footer ;;
98 clean)
99 check_root
100 _n 'Cleaning:'; echo " $root"
101 rm -rf ${root}/* ;;
102 grub-ex)
103 title 'GRUB config example'
104 grub_example
105 footer ;;
106 *)
107 iso="$1"
108 loop="/tmp/frugal-$$"
109 check_root
110 title 'SliTaz Frugal'
111 if [ ! -f "$iso" ]; then
112 _n 'Unable to find ISO image:'; colorize 31 " $iso"
113 newline; return 1
114 fi
115 mkdir -p ${root}
116 debug "$iso $root"
117 _n 'Mounting ISO image...'
118 mkdir -p ${loop}
119 mount -o loop "$iso" ${loop} 2>/dev/null
120 status
122 _n 'Installing the Kernel...'
123 cp -a ${loop}/boot/bzImage ${root}
124 status
126 _n 'Installing the root filesystem...'
127 if [ -f ${loop}/boot/rootfs1.gz ]; then
128 cd ${loop}/boot
129 cat $(ls -r rootfs*.gz) > ${root}/rootfs.gz
130 cd - >/dev/null
131 else
132 cp -a ${loop}/boot/rootfs.gz ${root}
133 fi
134 status
136 # Umount the loop device
137 _n 'Unmounting ISO image...'
138 sleep 1
139 umount ${loop} && rm -rf ${loop}
140 status
142 footer ;;
143 esac
145 exit 0