slitaz-tools view tinyutils/frugal @ rev 939

tazbox: fix subox icon when ~/.local/share/applications is absent; fix working with freegeoip; write full list of icons used; all other files: 2015 and insert blank lines.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Apr 17 07:35:02 2015 +0300 (2015-04-17)
parents a4f64dd9b359
children 3be081525506
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 . /usr/bin/gettext.sh
24 TEXTDOMAIN='slitaz-tools'
25 export TEXTDOMAIN
28 #
29 # Functions
30 #
33 # Small help and usage.
35 usage() {
36 name=$(basename $0)
37 cat << EOT
39 $(boldify $(gettext "Usage:")) $name [iso|command] [--options]
41 $(gettext "SliTaz frugal installation")
43 $(boldify $(gettext "Commands:"))
44 info $(gettext "Display install path and size stats")
45 clean $(gettext "Remove all frugal files")
46 grub-ex $(gettext "Show GRUB configuration example")
48 $(boldify $(gettext "Options:"))
49 --root= $(gettext "Set root installation path")
50 --debug $(gettext "Display some useful debug information")
52 $(boldify $(gettext "Examples:"))
53 $name slitaz-rolling.iso
54 $name slitaz-5.0.iso --root=/boot/frugal
56 EOT
57 }
60 # GRUB config example.
62 grub_example() {
63 cat << EOT
64 title SliTaz GNU/Linux (frugal)
65 root (hd0,0)
66 kernel /boot/frugal/bzImage root=/dev/null lang=en kmap=us
67 initrd /boot/frugal/rootfs.gz
68 EOT
69 }
72 #
73 # Commands
74 #
76 case "$1" in
77 "") usage ;;
78 info)
79 newline
80 boldify "Frugal info"
81 separator
83 # First check if we are running in frugal mode
84 if fgrep -q 'root=/dev/null' /proc/cmdline; then
85 gettext "Frugal system running detected"; newline
86 separator && newline && exit 0
87 fi
88 gettext "Installation directory:"; indent 30 $(colorize 36 "$root")
89 gettext "Kernel size:"
90 if [ -f "${root}/bzImage" ]; then
91 indent 30 $(du -sh ${root}/bzImage | awk '{print $1}')
92 else
93 indent 30 $(boldify "N/A")
94 fi
95 gettext "Rootfs size:"
96 if [ -f "${root}/rootfs.gz" ]; then
97 indent 30 $(du -sh ${root}/rootfs.gz | awk '{print $1}')
98 else
99 indent 30 $(boldify "N/A")
100 fi
101 separator && newline ;;
102 clean)
103 check_root
104 gettext "Cleaning:"; echo " $root"
105 rm -rf ${root}/* ;;
106 grub-ex)
107 newline
108 boldify "GRUB config example"
109 separator
110 grub_example
111 separator && newline ;;
112 *)
113 iso="$1"
114 loop="/tmp/frugal-$$"
115 check_root
116 newline
117 boldify "SliTaz Frugal"
118 separator
119 if [ ! -f "$iso" ]; then
120 gettext "Unable to find ISO image:"; colorize 31 " $iso"
121 newline && return 1
122 fi
123 mkdir -p ${root}
124 debug "$iso $root"
125 gettext "Mounting ISO image..."
126 mkdir -p ${loop}
127 mount -o loop "$iso" ${loop} 2>/dev/null
128 status
129 gettext "Installing the Kernel..."
130 cp -a ${loop}/boot/bzImage ${root}
131 status
132 gettext "Installing the root filesystem..."
133 if [ -f ${loop}/boot/rootfs1.gz ]; then
134 cd ${loop}/boot
135 cat $(ls -r rootfs*.gz) > ${root}/rootfs.gz
136 cd - >/dev/null
137 else
138 cp -a ${loop}/boot/rootfs.gz ${root}
139 fi
140 status
142 # Umount the loop device
143 gettext "Unmounting ISO image..."
144 sleep 1
145 umount ${loop} && rm -rf ${loop}
146 status
147 separator && newline ;;
148 esac
150 exit 0