rev |
line source |
pascal@17635
|
1 #!/bin/sh
|
pascal@17635
|
2
|
pascal@17635
|
3 [ $(id -u) -eq 0 ] || exec su -c "$0 $@"
|
pascal@17635
|
4
|
pascal@17635
|
5 DIALOG=dialog
|
pascal@17635
|
6
|
pascal@17635
|
7 ddq()
|
pascal@17635
|
8 {
|
pascal@17635
|
9 dd $@ 2> /dev/null
|
pascal@17635
|
10 }
|
pascal@17635
|
11
|
pascal@17635
|
12 get()
|
pascal@17635
|
13 {
|
pascal@17635
|
14 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
|
pascal@17635
|
15 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2
|
pascal@17635
|
16 }
|
pascal@17635
|
17
|
pascal@17635
|
18 bytes2bin()
|
pascal@17635
|
19 {
|
pascal@17635
|
20 for i in $@ ; do
|
pascal@17635
|
21 printf '\\\\x%02X' $(($i&255))
|
pascal@17635
|
22 done | xargs echo -en
|
pascal@17635
|
23 }
|
pascal@17635
|
24
|
pascal@17635
|
25 words2bin()
|
pascal@17635
|
26 {
|
pascal@17635
|
27 for i in $@ ; do
|
pascal@17635
|
28 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
|
pascal@17635
|
29 done | xargs echo -en
|
pascal@17635
|
30 }
|
pascal@17635
|
31
|
pascal@17635
|
32 gettazboot()
|
pascal@17635
|
33 {
|
pascal@17635
|
34 echo "Creating $(basename $1) ..."
|
pascal@17635
|
35 if [ $(get 0 $ISO) -eq 23117 ]; then
|
pascal@17635
|
36 O=$(($(get 66 $ISO) - 0xC0))
|
pascal@17635
|
37 L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O))
|
pascal@17635
|
38 S=$((32+$L))
|
pascal@17635
|
39 P=$((($S+511)/512))
|
pascal@17635
|
40 E=$((4096-(32*$P)))
|
pascal@17635
|
41 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
|
pascal@17635
|
42 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
|
pascal@17635
|
43 ddq bs=1 count=$L skip=$(echo $O) if=$ISO >> $1
|
pascal@17635
|
44 else
|
pascal@17635
|
45 wget -O $1 http://mirror.slitaz.org/boot/tazboot.exe
|
pascal@17635
|
46 fi
|
pascal@17635
|
47 }
|
pascal@17635
|
48
|
pascal@17635
|
49 uncpio()
|
pascal@17635
|
50 {
|
pascal@17635
|
51 [ -s "$1" ] || return
|
pascal@17635
|
52 echo -en "\n Extracting $(basename $1) ..."
|
pascal@17635
|
53 case $(get 0 $1) in
|
pascal@17635
|
54 *35615) ( zcat || gunzip ) ;;
|
pascal@17635
|
55 *14333) unxz ;;
|
pascal@17635
|
56 *\ 93) unlzma ;;
|
pascal@17635
|
57 *) cat ;;
|
pascal@17635
|
58 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
|
pascal@17635
|
59 }
|
pascal@17635
|
60
|
pascal@17635
|
61 dotwait()
|
pascal@17635
|
62 {
|
pascal@17635
|
63 echo -n "${1:-Install filesystem}.."
|
pascal@17635
|
64 touch /tmp/wait
|
pascal@17635
|
65 while [ -e /tmp/wait ]; do
|
pascal@17635
|
66 echo -n "." > /dev/tty
|
pascal@17635
|
67 sleep 1
|
pascal@17635
|
68 done &
|
pascal@17635
|
69 }
|
pascal@17635
|
70
|
pascal@17635
|
71 getuuid()
|
pascal@17635
|
72 {
|
pascal@17635
|
73 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
|
pascal@17635
|
74 [ "$dev" ] &&
|
pascal@17635
|
75 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
|
pascal@17635
|
76 echo "/dev/hda1"
|
pascal@17635
|
77 }
|
pascal@17635
|
78
|
pascal@17635
|
79 tazusbinitfs()
|
pascal@17635
|
80 {
|
pascal@17635
|
81 PAD=$(($(stat -c %s $1) % 4))
|
pascal@17635
|
82 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
|
pascal@17635
|
83 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
|
pascal@17635
|
84 cp -a /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
|
pascal@17635
|
85 cp -a /etc/keymap.conf /tmp/fs$$/etc 2> /dev/null
|
pascal@17635
|
86 cat > /tmp/fs$$/init1 <<EOT
|
pascal@17635
|
87 #!/bin/sh
|
pascal@17635
|
88 sed -i 's|sbin/init|init2|' /init
|
pascal@17635
|
89 exec /init
|
pascal@17635
|
90 EOT
|
pascal@17635
|
91 cat > /tmp/fs$$/init2 <<EOT
|
pascal@17635
|
92 #!/bin/sh
|
pascal@17635
|
93
|
pascal@17635
|
94 mount -t proc /proc /proc
|
pascal@17635
|
95 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@17635
|
96 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
|
pascal@17635
|
97 mount / -o remount,rw
|
pascal@17635
|
98 mkdir /mnt/dos
|
pascal@17635
|
99 rm -f /cmdline 2> /dev/null
|
pascal@17635
|
100 mount / -o remount,ro
|
pascal@17635
|
101 mnt=/mnt/dos/\${v#*/}
|
pascal@17635
|
102 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
|
pascal@17635
|
103 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
|
pascal@17635
|
104 mount \$dev /mnt/dos
|
pascal@17635
|
105 if [ ! -d /mnt/dos/slitaz ]; then
|
pascal@17635
|
106 umount /mnt/dos 2> /dev/null
|
pascal@17635
|
107 (blkid /dev/[sh]d* || blkid) | while read dev line; do
|
pascal@17635
|
108 case "\$line" in
|
pascal@17635
|
109 *ntfs*|*vfat*|*msdos*) ;;
|
pascal@17635
|
110 *) continue ;;
|
pascal@17635
|
111 esac
|
pascal@17635
|
112 mount \${dev%:} /mnt/dos
|
pascal@17635
|
113 [ -d /mnt/dos/slitaz ] && break
|
pascal@17635
|
114 umount /mnt/dos
|
pascal@17635
|
115 done
|
pascal@17635
|
116 fi
|
pascal@17635
|
117 mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
|
pascal@17635
|
118 mount --bind \$mnt /home
|
pascal@17635
|
119 umount /proc
|
pascal@17635
|
120 exec /sbin/init
|
pascal@17635
|
121 EOT
|
pascal@17635
|
122 chmod 755 /tmp/fs$$/init?
|
pascal@17635
|
123 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
|
pascal@17635
|
124 rm -rf /tmp/fs$$
|
pascal@17635
|
125 }
|
pascal@17635
|
126
|
pascal@17635
|
127 mkinitrd()
|
pascal@17635
|
128 {
|
pascal@17635
|
129 echo -en "\nCreating $(basename $1) "
|
pascal@17635
|
130 fs=/tmp/fs$$
|
pascal@17635
|
131 for i in bin lib dev proc tmp mnt etc ; do
|
pascal@17635
|
132 mkdir -p $fs/$i
|
pascal@17635
|
133 done
|
pascal@17635
|
134 for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/tty1 /dev/tty2 \
|
pascal@17635
|
135 /dev/fuse /dev/hd* /dev/sd* ; do
|
pascal@17635
|
136 cp -a $2$i $fs/dev/
|
pascal@17635
|
137 done
|
pascal@17635
|
138 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
|
pascal@17635
|
139 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
|
pascal@17635
|
140 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
|
pascal@17635
|
141 cp $i $fs/bin
|
pascal@17635
|
142 done
|
pascal@17635
|
143 cp -a /lib/ld-* $fs/lib
|
pascal@17635
|
144 for i in $(busybox | sed '/Current/,$!d'); do
|
pascal@17635
|
145 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
|
pascal@17635
|
146 done
|
pascal@17635
|
147 ln -s /proc/mounts $fs/etc/mtab
|
pascal@17635
|
148 sed 's/ .*//' /proc/modules | while read mod ; do
|
pascal@17635
|
149 find /lib/modules/ | grep $mod.ko | \
|
pascal@17635
|
150 sed 's|.*|cp & $fs/lib|' | sh
|
pascal@17635
|
151 done
|
pascal@17635
|
152 cat > $fs/init <<EOT
|
pascal@17635
|
153 #!/bin/sh
|
pascal@17635
|
154
|
pascal@17635
|
155 arg()
|
pascal@17635
|
156 {
|
pascal@17635
|
157 grep -q \$1 /proc/cmdline &&
|
pascal@17635
|
158 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
|
pascal@17635
|
159 echo "\$2 \$val"
|
pascal@17635
|
160 }
|
pascal@17635
|
161
|
pascal@17635
|
162 mount -t proc /proc /proc
|
pascal@17635
|
163 arg debug "shell" && debug=true && set -x
|
pascal@17635
|
164 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@17635
|
165 arg mount "Mount device"
|
pascal@17635
|
166 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
|
pascal@17635
|
167 arg subroot "Change root to directory"
|
pascal@17635
|
168 if [ -d /mnt/\$val ]; then
|
pascal@17635
|
169 umount /mnt 2> /dev/null
|
pascal@17635
|
170 (blkid /dev/[sh]d* || blkid) | while read dev line; do
|
pascal@17635
|
171 case "\$line" in
|
pascal@17635
|
172 *ntfs*|*vfat*|*msdos*) ;;
|
pascal@17635
|
173 *) continue ;;
|
pascal@17635
|
174 esac
|
pascal@17635
|
175 mount \${dev%:} /mnt
|
pascal@17635
|
176 [ -d /mnt/\$val ] && break
|
pascal@17635
|
177 umount /mnt
|
pascal@17635
|
178 done
|
pascal@17635
|
179 fi
|
pascal@17635
|
180 mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
|
pascal@17635
|
181 mount --bind /mnt /mnt/\$val/mnt/dos
|
pascal@17635
|
182 mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
|
pascal@17635
|
183 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
|
pascal@17635
|
184 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
|
pascal@17635
|
185 [ "$debug" = "true" ] && sh
|
pascal@17635
|
186 umount /proc
|
pascal@17635
|
187 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
|
pascal@17635
|
188 EOT
|
pascal@17635
|
189 chmod +x $fs/init
|
pascal@17635
|
190 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
|
pascal@17635
|
191 rm -rf $fs /tmp/wait
|
pascal@17635
|
192 }
|
pascal@17635
|
193
|
pascal@17635
|
194 ls_r()
|
pascal@17635
|
195 {
|
pascal@17635
|
196 ls -r $@ 2> /dev/null || ls $@
|
pascal@17635
|
197 }
|
pascal@17635
|
198
|
pascal@17635
|
199 doinstall()
|
pascal@17635
|
200 {
|
pascal@17635
|
201 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
|
pascal@17635
|
202 if ! mount.posixovl -F $mnt/slitaz -- \
|
pascal@17635
|
203 -oallow_other -odefault_permissions -osuid; then
|
pascal@17635
|
204 echo "Can't install SliTaz. Abort."
|
pascal@17635
|
205 sleep 5
|
pascal@17635
|
206 return 1
|
pascal@17635
|
207 fi
|
pascal@17635
|
208 dotwait "Install root filesystem in /slitaz.."
|
pascal@17635
|
209 if [ "$1" ]; then
|
pascal@17635
|
210 ls_r /media/cdrom/boot/rootfs*gz | \
|
pascal@17635
|
211 xargs cat > $mnt/slitaz/boot/rootfs.gz
|
pascal@17635
|
212 tazusbinitfs $mnt/slitaz/boot/rootfs.gz
|
pascal@17635
|
213 initrd=rootfs.gz
|
pascal@17635
|
214 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
|
pascal@17635
|
215 else
|
pascal@17635
|
216 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
|
pascal@17635
|
217 uncpio $i $mnt/slitaz
|
pascal@17635
|
218 done
|
pascal@17635
|
219 for i in $packages_list; do
|
pascal@17635
|
220 tazpkg get-install $i --root=$mnt/slitaz
|
pascal@17635
|
221 done
|
pascal@17635
|
222 for i in $packages_dir/*.tazpkg; do
|
pascal@17635
|
223 [ -s "$i" ] &&
|
pascal@17635
|
224 tazpkg install $i --root=$mnt/slitaz
|
pascal@17635
|
225 done
|
pascal@17635
|
226 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
|
pascal@17635
|
227 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
|
pascal@17635
|
228 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz
|
pascal@17635
|
229 initrd=initrd
|
pascal@17635
|
230 extraargs="mount=$(getuuid) subroot=slitaz"
|
pascal@17635
|
231 fi
|
pascal@17635
|
232 echo -en "\nInstall boot files..."
|
pascal@17635
|
233 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
|
pascal@17635
|
234 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
|
pascal@17635
|
235 /media/cdrom/README /media/cdrom/boot/memtest* ; do
|
pascal@17635
|
236 [ -s $i ] && cp $i $mnt/slitaz/boot
|
pascal@17635
|
237 done
|
pascal@17635
|
238 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe* ; do
|
pascal@17635
|
239 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
|
pascal@17635
|
240 mv $i $i.exe
|
pascal@17635
|
241 done
|
pascal@17635
|
242 gettazboot $mnt/slitaz/boot/tazboot.exe
|
pascal@17635
|
243 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
|
pascal@17635
|
244 kernel=/slitaz/boot/bzimage
|
pascal@17635
|
245 initrd=/slitaz/boot/$initrd
|
pascal@17635
|
246 rw root=/dev/null $extraargs autologin
|
pascal@17635
|
247 EOT
|
pascal@17635
|
248 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
|
pascal@17635
|
249 $mnt/slitaz/boot/README
|
pascal@17635
|
250 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
|
pascal@17635
|
251 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
|
pascal@17635
|
252 rm -f /tmp/wait
|
pascal@17635
|
253 umount $mnt/slitaz
|
pascal@17635
|
254 return 0
|
pascal@17635
|
255 }
|
pascal@17635
|
256
|
pascal@17635
|
257 windev()
|
pascal@17635
|
258 {
|
pascal@17635
|
259 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs)" | sed 's/:.*//;s|/dev/||')"
|
pascal@17635
|
260 [ "$DEV" ] || return
|
pascal@17635
|
261 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
262 $DIALOG --clear \
|
pascal@17635
|
263 --title " Select your Windows partition " \
|
pascal@17635
|
264 --menu "\nPlease select the Windows partition according to its known size.
|
pascal@17635
|
265 The datas will be kept untouched.\n" \
|
pascal@17635
|
266 17 70 8 \
|
pascal@17635
|
267 $(for i in $DEV ; do
|
pascal@17635
|
268 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
|
pascal@17635
|
269 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
|
pascal@17635
|
270 done)
|
pascal@17635
|
271 EOT
|
pascal@17635
|
272 exec 3>&1
|
pascal@17635
|
273 [ $? -eq 0 ] || return
|
pascal@17635
|
274 device=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17635
|
275 exec 3>&-
|
pascal@17635
|
276 rm -f /tmp/dialog$$
|
pascal@17635
|
277 mnt=/tmp/mnt$$
|
pascal@17635
|
278 mkdir -p $mnt && mount $device $mnt
|
pascal@17635
|
279 }
|
pascal@17635
|
280
|
pascal@17635
|
281 extra_packages()
|
pascal@17635
|
282 {
|
pascal@17635
|
283 packages_list=
|
pascal@17635
|
284 packages_dir=
|
pascal@17635
|
285 $DIALOG --clear \
|
pascal@17635
|
286 --title " Extra packages " \
|
pascal@17635
|
287 --defaultno --yesno \
|
pascal@17635
|
288 "
|
pascal@17635
|
289 Do you want to add extra packages ?
|
pascal@17635
|
290 " 7 70
|
pascal@17635
|
291 [ $? -eq 0 ] || return
|
pascal@17635
|
292 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
|
pascal@17635
|
293 if [ -s /media/cdrom/boot/vmlinuz-$(uname -r) ]; then
|
pascal@17635
|
294 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
295 $DIALOG --clear \
|
pascal@17635
|
296 --title " Select the packages " \
|
pascal@17635
|
297 --separate-output \
|
pascal@17635
|
298 --cancel-label "Skip" \
|
pascal@17635
|
299 --checklist "Please select the packages you want to install. Try with the first letter." \
|
pascal@17635
|
300 23 78 20 \\
|
pascal@17635
|
301 EOT
|
pascal@17635
|
302 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
|
pascal@17635
|
303 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
|
pascal@17635
|
304 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
|
pascal@17635
|
305 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
|
pascal@17635
|
306 fi
|
pascal@17635
|
307 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
308 $DIALOG --clear \
|
pascal@17635
|
309 --title "Please select the directory with every custom packages to install." \
|
pascal@17635
|
310 --cancel-label "Skip" \
|
pascal@17635
|
311 --dselect $PWD 13 78
|
pascal@17635
|
312 EOT
|
pascal@17635
|
313 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
|
pascal@17635
|
314 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
|
pascal@17635
|
315 rm -f /tmp/dialog$$ /tmp/dialog.out$$
|
pascal@17635
|
316 }
|
pascal@17635
|
317
|
pascal@17635
|
318 _install()
|
pascal@17635
|
319 {
|
pascal@17635
|
320 extra_packages
|
pascal@17635
|
321 $DIALOG --clear \
|
pascal@17635
|
322 --title " SliTaz UMSDOS way installation " \
|
pascal@17635
|
323 --yes-label "Install" --yesno \
|
pascal@17635
|
324 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
pascal@17635
|
325 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
|
pascal@17635
|
326 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@17635
|
327 To uninstall SliTaz, you have only to remove this directory.
|
pascal@17635
|
328 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@17635
|
329 SliTaz may run slowly on 'UMSDOS way' installation due to the
|
pascal@17635
|
330 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
|
pascal@17635
|
331 To do a traditional installation with disk partitioning,
|
pascal@17635
|
332 start SliTaz Live with 'SliTaz RAM boot' menu.\n
|
pascal@17635
|
333 " 19 70
|
pascal@17635
|
334 [ $? -eq 0 ] || return
|
pascal@17635
|
335 doinstall
|
pascal@17635
|
336 }
|
pascal@17635
|
337
|
pascal@17635
|
338 readtazbootconf()
|
pascal@17635
|
339 {
|
pascal@17635
|
340 kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
341 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
342 cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
343 }
|
pascal@17635
|
344
|
pascal@17635
|
345 bootinstalled()
|
pascal@17635
|
346 {
|
pascal@17635
|
347 [ "$(which kexec)" ] || return
|
pascal@17635
|
348 [ -x $mnt/slitaz$1 ] || return
|
pascal@17635
|
349 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
|
pascal@17635
|
350 readtazbootconf
|
pascal@17659
|
351 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
|
pascal@17635
|
352 umount $mnt
|
pascal@17635
|
353 rm -rf $mnt
|
pascal@17635
|
354 umount -d /media/cdrom
|
pascal@17635
|
355 kexec -e
|
pascal@17635
|
356 }
|
pascal@17635
|
357
|
pascal@17635
|
358 mkzip()
|
pascal@17635
|
359 {
|
pascal@17635
|
360 device=
|
pascal@17635
|
361 packages_list=
|
pascal@17635
|
362 packages_dir=
|
pascal@17635
|
363 mnt=/tmp/mnt$$
|
pascal@17635
|
364 mkdir -p $mnt
|
pascal@17635
|
365 $1 || return
|
pascal@17635
|
366 wget -O $mnt/slitaz/boot/grldr http://mirror.slitaz.org/boot/grldr
|
pascal@17635
|
367 readtazbootconf
|
pascal@17636
|
368 cat > $mnt/slitaz/boot/menu.lst <<EOT
|
pascal@17635
|
369 title SliTaz
|
pascal@17635
|
370 kernel $kernel $cmdline
|
pascal@17635
|
371 initrd $initrd
|
pascal@17635
|
372
|
pascal@17635
|
373 EOT
|
pascal@17635
|
374 while read file title; do
|
pascal@17637
|
375 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
|
pascal@17637
|
376 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
|
pascal@17635
|
377 title $title
|
pascal@17637
|
378 kernel ${file#$mnt}
|
pascal@17635
|
379
|
pascal@17635
|
380 EOT
|
pascal@17635
|
381 done <<EOT
|
pascal@17635
|
382 memtest MemTest
|
pascal@17635
|
383 pxe Web boot
|
pascal@17635
|
384 EOT
|
pascal@17636
|
385 unix2dos $mnt/slitaz/boot/menu.lst
|
pascal@17636
|
386 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
|
pascal@17659
|
387 For DOS users (real mode only):
|
pascal@17659
|
388
|
pascal@17659
|
389 Start SliTaz with \\slitaz\\boot\\tazboot.exe
|
pascal@17659
|
390
|
pascal@17659
|
391
|
pascal@17635
|
392 For NT/2000/XP users:
|
pascal@17635
|
393
|
pascal@17635
|
394 1- Move the files grldr and menu.lst into the root directory
|
pascal@17635
|
395
|
pascal@17635
|
396 C:\\> copy \\slitaz\\boot\\grldr \\
|
pascal@17635
|
397 C:\\> copy \\slitaz\\boot\\menu.lst \\
|
pascal@17635
|
398
|
pascal@17635
|
399 2- Remove boot.ini attributes
|
pascal@17635
|
400
|
pascal@17635
|
401 C:\\> attrib -r -h -s boot.ini
|
pascal@17635
|
402
|
pascal@17635
|
403 3- Append the following line to boot.init
|
pascal@17635
|
404
|
pascal@17635
|
405 C:\\grldr="slitaz"
|
pascal@17635
|
406
|
pascal@17635
|
407 4- Restore boot.ini attributes
|
pascal@17635
|
408
|
pascal@17635
|
409 C:\\> attrib +r +h +s boot.ini
|
pascal@17635
|
410
|
pascal@17635
|
411 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
|
pascal@17635
|
412 EOT
|
pascal@17636
|
413 ( cd $mnt ; zip -r9 $(basename $ISO .iso).zip slitaz )
|
pascal@17635
|
414 mv $mnt/*.zip .
|
pascal@17636
|
415 umount $mnt
|
pascal@17636
|
416 rm -rf $mnt
|
pascal@17635
|
417 }
|
pascal@17635
|
418
|
pascal@17635
|
419 install()
|
pascal@17635
|
420 {
|
pascal@17635
|
421 windev || return
|
pascal@17635
|
422 packages_list=
|
pascal@17635
|
423 packages_dir=
|
pascal@17635
|
424 _install && bootinstalled /sbin/init
|
pascal@17635
|
425 umount $mnt
|
pascal@17635
|
426 rm -rf $mnt
|
pascal@17635
|
427 }
|
pascal@17635
|
428
|
pascal@17635
|
429 inst2zip()
|
pascal@17635
|
430 {
|
pascal@17635
|
431 mkzip _install
|
pascal@17635
|
432 }
|
pascal@17635
|
433
|
pascal@17635
|
434 _installtaz()
|
pascal@17635
|
435 {
|
pascal@17635
|
436 $DIALOG --clear \
|
pascal@17635
|
437 --title " SliTaz TAZUSB way installation " \
|
pascal@17635
|
438 --yes-label "Install" --yesno \
|
pascal@17635
|
439 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
pascal@17635
|
440 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
|
pascal@17635
|
441 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@17635
|
442 To uninstall SliTaz, you have only to remove this directory.
|
pascal@17635
|
443 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@17635
|
444 The filesystem is loaded entirely into memory upon boot to
|
pascal@17635
|
445 increase responsiveness. Only /home lands on hard disk.\n\n
|
pascal@17635
|
446 To do a traditional installation with disk partitioning,
|
pascal@17635
|
447 start SliTaz Live with 'SliTaz RAM boot' menu.\n
|
pascal@17635
|
448 " 19 70
|
pascal@17635
|
449 [ $? -eq 0 ] || return
|
pascal@17635
|
450 doinstall tazusblike
|
pascal@17635
|
451 }
|
pascal@17635
|
452
|
pascal@17635
|
453 installtaz()
|
pascal@17635
|
454 {
|
pascal@17635
|
455 windev || return
|
pascal@17635
|
456 packages_list=
|
pascal@17635
|
457 packages_dir=
|
pascal@17635
|
458 _installtaz && bootinstalled /boot/bzimage
|
pascal@17635
|
459 umount $mnt
|
pascal@17635
|
460 rm -rf $mnt
|
pascal@17635
|
461 }
|
pascal@17635
|
462
|
pascal@17635
|
463 insttaz2zip()
|
pascal@17635
|
464 {
|
pascal@17635
|
465 mkzip _installtaz
|
pascal@17635
|
466 }
|
pascal@17635
|
467
|
pascal@17635
|
468 bootiso()
|
pascal@17635
|
469 {
|
pascal@17635
|
470 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
|
pascal@17635
|
471 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
|
pascal@17635
|
472 cat $i
|
pascal@17635
|
473 n=$((4 - ($(stat -c %s $i) % 4)))
|
pascal@17635
|
474 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
|
pascal@17635
|
475 done > /tmp/initrd$$
|
pascal@17635
|
476 kernel=/media/cdrom/boot/bzImage
|
pascal@17635
|
477 grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
|
pascal@17635
|
478 . /etc/locale.conf
|
pascal@17659
|
479 kexec -l $kernel --initrd /tmp/initrd$$ --command-line \
|
pascal@17659
|
480 "root=/dev/null autologin lang=$LANG kmap=$(cat /etc/keymap.conf)" &&
|
pascal@17635
|
481 umount -d /media/cdrom
|
pascal@17659
|
482 rm -f /tmp/initrd$$
|
pascal@17635
|
483 kexec -e
|
pascal@17635
|
484 }
|
pascal@17635
|
485
|
pascal@17635
|
486 tazboot()
|
pascal@17635
|
487 {
|
pascal@17635
|
488 $DIALOG --clear \
|
pascal@17635
|
489 --title " SliTaz bootloader for DOS " \
|
pascal@17635
|
490 --yes-label "Install" --yesno \
|
pascal@17635
|
491 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
|
pascal@17635
|
492 any linux kernel, multiple initramfs, a kernel command line and
|
pascal@17635
|
493 an ISO image file loopback (retrieves files from an ISO file).\n\n
|
pascal@17635
|
494 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
|
pascal@17635
|
495 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
|
pascal@17635
|
496 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
|
pascal@17635
|
497 Examples for tazboot.cmd:\n\n\
|
pascal@17635
|
498 bootfrom=\\isos\\slitaz-4.0.iso\n\
|
pascal@17635
|
499 kernel=boot/bzImage\n\
|
pascal@17635
|
500 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
|
pascal@17635
|
501 rw root=/dev/null autologin\n\n\
|
pascal@17635
|
502 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
|
pascal@17635
|
503 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n
|
pascal@17635
|
504 " 24 78
|
pascal@17635
|
505 [ $? -eq 0 ] || return
|
pascal@17635
|
506 gettazboot tazboot.exe
|
pascal@17635
|
507 }
|
pascal@17635
|
508
|
pascal@17635
|
509 md5()
|
pascal@17635
|
510 {
|
pascal@17635
|
511 dotwait "Checking files"
|
pascal@17635
|
512 ( cd /media/cdrom ; ${1:-md5sum -c md5sum*} ) > /tmp/data
|
pascal@17635
|
513 rm -f /tmp/wait
|
pascal@17635
|
514 $DIALOG --clear \
|
pascal@17635
|
515 --title " Checked files " \
|
pascal@17635
|
516 --textbox /tmp/data 24 78
|
pascal@17635
|
517 rm -f /tmp/data
|
pascal@17635
|
518 }
|
pascal@17635
|
519
|
pascal@17635
|
520 gotcdfile()
|
pascal@17635
|
521 {
|
pascal@17635
|
522 for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \
|
pascal@17635
|
523 "/media/cdrom/*/isolinux/$1" ; do
|
pascal@17635
|
524 file=$(ls $i 2> /dev/null | sed q)
|
pascal@17635
|
525 [ -s "$file" ] && break
|
pascal@17635
|
526 done
|
pascal@17635
|
527 }
|
pascal@17635
|
528
|
pascal@17635
|
529 sha()
|
pascal@17635
|
530 {
|
pascal@17635
|
531 gotcdfile 'sha*sum*'
|
pascal@17635
|
532 sha=$(basename $file)
|
pascal@17635
|
533 md5 "${sha%sum*}sum -c ${file#/media/cdrom/}"
|
pascal@17635
|
534 }
|
pascal@17635
|
535
|
pascal@17635
|
536 readme()
|
pascal@17635
|
537 {
|
pascal@17635
|
538 gotcdfile 'README*'
|
pascal@17635
|
539 $DIALOG --clear \
|
pascal@17635
|
540 --title " Readme " \
|
pascal@17635
|
541 --textbox $file 24 78
|
pascal@17635
|
542 }
|
pascal@17635
|
543
|
pascal@17635
|
544 bzimage()
|
pascal@17635
|
545 {
|
pascal@17635
|
546 $DIALOG --clear \
|
pascal@17635
|
547 --title " Create linux.exe ? " \
|
pascal@17635
|
548 --yes-label "Install" --yesno \
|
pascal@17635
|
549 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
|
pascal@17635
|
550 The cmdline arguments are supported except initrd=,
|
pascal@17635
|
551 vga= (you can try 'rdev -v') and mem= (partially).
|
pascal@17635
|
552 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n
|
pascal@17635
|
553 " 12 70
|
pascal@17635
|
554 [ $? -eq 0 ] || return
|
pascal@17635
|
555 cp /media/cdrom/boot/bzImage linux.exe
|
pascal@17635
|
556 }
|
pascal@17635
|
557
|
pascal@17635
|
558 memtest()
|
pascal@17635
|
559 {
|
pascal@17635
|
560 $DIALOG --clear \
|
pascal@17635
|
561 --title " Create memtest.exe ? " \
|
pascal@17635
|
562 --yes-label "Install" --yesno \
|
pascal@17635
|
563 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@17635
|
564 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@17635
|
565 miss many of the failures that are detected by Memtest86.\n
|
pascal@17635
|
566 " 12 70
|
pascal@17635
|
567 [ $? -eq 0 ] && gotcdfile 'memtest*' && cp $file memtest.exe
|
pascal@17635
|
568 }
|
pascal@17635
|
569
|
pascal@17635
|
570 mkfat12()
|
pascal@17635
|
571 {
|
pascal@17635
|
572 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
|
pascal@17635
|
573 J=$(($(get 3 $1 1) + 0x02))
|
pascal@17635
|
574 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
|
pascal@17635
|
575 [ $R -lt 2500 ] || return
|
pascal@17635
|
576 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
|
pascal@17635
|
577 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
|
pascal@17635
|
578 G="18 0 2 0 0 0 0 0"
|
pascal@17635
|
579 [ $J -gt 25 ] || G=""
|
pascal@17635
|
580 F=0
|
pascal@17635
|
581 for i in 1 2 3; do
|
pascal@17635
|
582 F=$((((2880-$R-$F-$F)*3+1023)/1024))
|
pascal@17635
|
583 done
|
pascal@17635
|
584 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
|
pascal@17635
|
585 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
|
pascal@17635
|
586 $G | ddq bs=1 of=/dev/fd0
|
pascal@17635
|
587 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
|
pascal@17635
|
588 for i in $R $(($R+$F)) ; do
|
pascal@17635
|
589 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
|
pascal@17635
|
590 done
|
pascal@17635
|
591 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
|
pascal@17635
|
592 }
|
pascal@17635
|
593
|
pascal@17635
|
594 mkfloppy()
|
pascal@17635
|
595 {
|
pascal@17635
|
596 dotwait "Create a $(basename $1) boot floppy"
|
pascal@17635
|
597 ddq if=$1 of=/dev/fd0
|
pascal@17635
|
598 mkfat12 $1
|
pascal@17635
|
599 rm -f /tmp/wait
|
pascal@17635
|
600 }
|
pascal@17635
|
601
|
pascal@17635
|
602 fdmemtest()
|
pascal@17635
|
603 {
|
pascal@17635
|
604 $DIALOG --clear \
|
pascal@17635
|
605 --title " Create a Memtest86 boot floppy " \
|
pascal@17635
|
606 --yes-label "Create floppy" --yesno \
|
pascal@17635
|
607 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@17635
|
608 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@17635
|
609 miss many of the failures that are detected by Memtest86.\n\n
|
pascal@17635
|
610 Please insert a blank disk in floppy drive.\n
|
pascal@17635
|
611 " 12 70
|
pascal@17635
|
612 [ $? -eq 0 ] && gotcdfile 'memtest*' && mkfloppy $file
|
pascal@17635
|
613 }
|
pascal@17635
|
614
|
pascal@17635
|
615 pxe()
|
pascal@17635
|
616 {
|
pascal@17635
|
617 gotcdfile '?pxe'
|
pascal@17635
|
618 $DIALOG --clear \
|
pascal@17635
|
619 --title " Create $(basename $file).exe ? " \
|
pascal@17635
|
620 --yes-label "Install" --yesno \
|
pascal@17635
|
621 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@17635
|
622 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@17635
|
623 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@17635
|
624 from the Web using PXE and HTTP protocols.\n
|
pascal@17635
|
625 " 12 70
|
pascal@17635
|
626 [ $? -eq 0 ] || return
|
pascal@17635
|
627 cp $file $(basename $file).exe
|
pascal@17635
|
628 }
|
pascal@17635
|
629
|
pascal@17635
|
630 fdpxe()
|
pascal@17635
|
631 {
|
pascal@17635
|
632 $DIALOG --clear \
|
pascal@17635
|
633 --title " Create a SliTaz Web boot floppy " \
|
pascal@17635
|
634 --yes-label "Create floppy" --yesno \
|
pascal@17635
|
635 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@17635
|
636 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@17635
|
637 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@17635
|
638 from the Web using PXE and HTTP protocols.\n\n
|
pascal@17635
|
639 Please insert a blank disk in floppy drive.\n
|
pascal@17635
|
640 " 12 70
|
pascal@17635
|
641 [ $? -eq 0 ] && gotcdfile '?pxe' && mkfloppy $file
|
pascal@17635
|
642 }
|
pascal@17635
|
643
|
pascal@17635
|
644 gotposixovl()
|
pascal@17635
|
645 {
|
pascal@17635
|
646 mount.posixovl 2>&1 | grep -qi usage &&
|
pascal@17635
|
647 echo -en "\"$1\" \"$2\""
|
pascal@17635
|
648 }
|
pascal@17635
|
649
|
pascal@17635
|
650 gotposixovlzip()
|
pascal@17635
|
651 {
|
pascal@17635
|
652 [ "$(which zip)" ] && gotposixovl "$1" "$2"
|
pascal@17635
|
653 }
|
pascal@17635
|
654
|
pascal@17635
|
655 xfile()
|
pascal@17635
|
656 {
|
pascal@17635
|
657 [ "$(which $1)" ] && echo -en "\"$2\" \"$3\""
|
pascal@17635
|
658 }
|
pascal@17635
|
659
|
pascal@17635
|
660 cdfile()
|
pascal@17635
|
661 {
|
pascal@17635
|
662 gotcdfile "$1" && echo -en "\"$2\" \"$3\""
|
pascal@17635
|
663 }
|
pascal@17635
|
664
|
pascal@17659
|
665 isbzImage()
|
pascal@17659
|
666 {
|
pascal@17659
|
667 [ $(get 514 $file 4) -eq 1400005704 ] &&
|
pascal@17659
|
668 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
|
pascal@17659
|
669 }
|
pascal@17659
|
670
|
pascal@17635
|
671 cdfilex()
|
pascal@17635
|
672 {
|
pascal@17659
|
673 gotcdfile "$1" &&
|
pascal@17659
|
674 [ "$(which kexec)" ] &&
|
pascal@17659
|
675 isbzImage &&
|
pascal@17659
|
676 echo -en "\"$2\" \"$3\""
|
pascal@17635
|
677 }
|
pascal@17635
|
678
|
pascal@17635
|
679 cdfilef()
|
pascal@17635
|
680 {
|
pascal@17635
|
681 [ -e /sys/block/fd0 ] && cdfile "$@"
|
pascal@17635
|
682 }
|
pascal@17635
|
683
|
pascal@17635
|
684 cdexe()
|
pascal@17635
|
685 {
|
pascal@17635
|
686 gotcdfile "$1" &&
|
pascal@17635
|
687 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
|
pascal@17635
|
688 echo -en "\"$2\" \"$3\""
|
pascal@17635
|
689 }
|
pascal@17635
|
690
|
pascal@17635
|
691 misspkg()
|
pascal@17635
|
692 {
|
pascal@17635
|
693 for i in zip kexec-tools posixovl ; do
|
pascal@17635
|
694 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
|
pascal@17635
|
695 [ "$1" != "install" ] &&
|
pascal@17635
|
696 echo -en "\"$1\" \"$2\"" && return
|
pascal@17635
|
697 tazpkg get-install $i
|
pascal@17635
|
698 done
|
pascal@17635
|
699 }
|
pascal@17635
|
700
|
pascal@17635
|
701 missing()
|
pascal@17635
|
702 {
|
pascal@17635
|
703 misspkg install
|
pascal@17635
|
704 }
|
pascal@17635
|
705
|
pascal@17635
|
706 ishybrid()
|
pascal@17635
|
707 {
|
pascal@17635
|
708 C=$((2048*$(get $(((17*2048) + 71)) $ISO 4)))
|
pascal@17635
|
709 [ $(get $C $ISO 4) -eq 1 ] || return
|
pascal@17635
|
710 [ $(get $(($C+30)) $ISO 4) -eq $((0x88AA55)) ] || return
|
pascal@17635
|
711 C=$((2048*$(get $(($C+40)) $ISO 4)))
|
pascal@17635
|
712 [ $(get $(($C+64)) $ISO 4) -eq 1886961915 ] &&
|
pascal@17635
|
713 echo -en "\"$1\" \"$2\""
|
pascal@17635
|
714 }
|
pascal@17635
|
715
|
pascal@17635
|
716 isiso()
|
pascal@17635
|
717 {
|
pascal@17635
|
718 [ $(get 32769 $ISO 4) -eq 808469571 ] &&
|
pascal@17635
|
719 echo -en "\"$1\" \"$2\""
|
pascal@17635
|
720 }
|
pascal@17635
|
721
|
pascal@17635
|
722 gotisomd5()
|
pascal@17635
|
723 {
|
pascal@17635
|
724 [ "$(which md5sum 2> /dev/null)" ] &&
|
pascal@17635
|
725 [ $(get 0 $ISO) -eq 23117 ] &&
|
pascal@17635
|
726 [ $(get 18 $ISO) -ne 0 ] && echo -en "\"$1\" \"$2\""
|
pascal@17635
|
727 }
|
pascal@17635
|
728
|
pascal@17635
|
729 isomd5()
|
pascal@17635
|
730 {
|
pascal@17635
|
731 dotwait "Checking iso image"
|
pascal@17635
|
732 [ "$(ddq if=$ISO bs=2k skip=16 \
|
pascal@17635
|
733 count=$(echo $(get 32848 $ISO 4)) | md5sum)" == \
|
pascal@17635
|
734 "$(ddq if=$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
|
pascal@17635
|
735 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
|
pascal@17635
|
736 echo -en "\rChecking iso hybrid boot..."
|
pascal@17635
|
737 n=$(($(get 2 $ISO)-1+($(get 4 $ISO)-1)*512))
|
pascal@17635
|
738 if [ $n -lt 40000 -a $n -gt 32768 ]; then
|
pascal@17635
|
739 s=$(get 0 $ISO 2 $n | awk '{ i+= $0 } END { print i }')
|
pascal@17635
|
740 [ $(((1+$s+$(get $(($n+1)) $ISO 1)) % 65536)) -eq 0 ] &&
|
pascal@17635
|
741 echo "OK" || echo "ERROR"
|
pascal@17635
|
742 fi
|
pascal@17635
|
743 rm -f /tmp/wait
|
pascal@17635
|
744 echo -e "\rPress RETURN to continue."
|
pascal@17635
|
745 read n
|
pascal@17635
|
746 }
|
pascal@17635
|
747
|
pascal@17635
|
748 usbdev()
|
pascal@17635
|
749 {
|
pascal@17635
|
750 dotwait "Wait 5 seconds for USB devices"
|
pascal@17635
|
751 sleep 5
|
pascal@17635
|
752 rm -f /tmp/wait
|
pascal@17635
|
753 DEV="$(grep -l 1 /sys/block/*/removable | \
|
pascal@17635
|
754 sed 's|/sys/block/\(.*\)/removable|\1|')"
|
pascal@17635
|
755 grep -qs 1 /sys/block/$DEV/ro && return
|
pascal@17635
|
756 [ "$DEV" ] || return
|
pascal@17635
|
757 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
758 $DIALOG --clear \
|
pascal@17635
|
759 --title " Select your USB key " \
|
pascal@17635
|
760 --menu "\nPlease select the USB key according to its known size.\n\n" \
|
pascal@17635
|
761 14 70 4 \
|
pascal@17635
|
762 $(for i in $DEV ; do
|
pascal@17635
|
763 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
|
pascal@17635
|
764 done) \
|
pascal@17635
|
765
|
pascal@17635
|
766 EOT
|
pascal@17635
|
767 exec 3>&1
|
pascal@17635
|
768 device=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17635
|
769 rm -f /tmp/dialog$$
|
pascal@17635
|
770 retval=$?
|
pascal@17635
|
771 exec 3>&-
|
pascal@17635
|
772 rm -f /tmp/dialog$$
|
pascal@17635
|
773 [ $retval -eq 0 ]
|
pascal@17635
|
774 }
|
pascal@17635
|
775
|
pascal@17635
|
776 tazusbmsg()
|
pascal@17635
|
777 {
|
pascal@17635
|
778 [ "$(which tazusb 2> /dev/null)" ] || return
|
pascal@17635
|
779 echo "You should choose 'USB key read/write installation' to be
|
pascal@17635
|
780 able to save the package updates or your own configuration and data files.\n\n"
|
pascal@17635
|
781 }
|
pascal@17635
|
782
|
pascal@17635
|
783 usbbootkey()
|
pascal@17635
|
784 {
|
pascal@17635
|
785 $DIALOG --clear \
|
pascal@17635
|
786 --title " Create a USB boot key " \
|
pascal@17635
|
787 --yes-label "Continue" --yesno \
|
pascal@17635
|
788 "\nThe USB key will be used like a CD-ROM. You will not be able to write
|
pascal@17635
|
789 any data on the boot partition.\n\n
|
pascal@17635
|
790 An extra FAT32 partition will be created with the remaining free space.\n\n
|
pascal@17635
|
791 $(tazusbmsg)Please plug your USB stick in now.\n
|
pascal@17635
|
792 " 16 70
|
pascal@17635
|
793 [ $? -eq 0 ] || return
|
pascal@17635
|
794 usbdev || return
|
pascal@17635
|
795
|
pascal@17635
|
796 # perform dd in progess bar
|
pascal@17635
|
797 max=$(($(stat -c %s $ISO)/2048))
|
pascal@17635
|
798 i=0; ddq if=$ISO bs=1024k | (
|
pascal@17635
|
799 while ddq bs=1024k count=1 ; do
|
pascal@17635
|
800 i=$(($i + 1))
|
pascal@17635
|
801 [ $i -gt $max ] && break
|
pascal@17635
|
802 echo $((($i*100)/$max)) | dialog --gauge \
|
pascal@17635
|
803 " The ISO image transfer can be long. Please wait..." \
|
pascal@17635
|
804 6 70 0 > /dev/tty 2>&1
|
pascal@17635
|
805 done ) > $device
|
pascal@17635
|
806
|
pascal@17635
|
807 # partition + fat32 format for the remining space
|
pascal@17635
|
808 get 446 $device 2 12 | xargs echo | { read dx cx ol oh ll lh
|
pascal@17635
|
809 if [ $dx -eq $((0x3F17)) ]; then
|
pascal@17635
|
810 cx=$(($cx & 0xFF00))
|
pascal@17635
|
811 ofs=$(($ll+($lh<<16)))
|
pascal@17635
|
812 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
|
pascal@17635
|
813 m=$(($cx+($n/8)))
|
pascal@17635
|
814 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
|
pascal@17635
|
815 m=$((($m & 0xFF00)+(($m>>16)<<6)))
|
pascal@17635
|
816 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
|
pascal@17635
|
817 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
|
pascal@17635
|
818 ddq bs=1 seek=446 of=$device
|
pascal@17635
|
819 if [ "$(which mkdosfs 2> /dev/null)" ]; then
|
pascal@17635
|
820 losetup -o $((512*$ofs)) /dev/loop2 $device
|
pascal@17635
|
821 mkdosfs -n "SLITAZ BOOT" /dev/loop2
|
pascal@17635
|
822 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
|
pascal@17635
|
823 ddq bs=1 seek=28 of=/dev/loop2
|
pascal@17635
|
824 losetup -d /dev/loop2
|
pascal@17635
|
825 fi
|
pascal@17635
|
826 fi ; }
|
pascal@17635
|
827 }
|
pascal@17635
|
828
|
pascal@17635
|
829 usbkey()
|
pascal@17635
|
830 {
|
pascal@17635
|
831 $DIALOG --clear \
|
pascal@17635
|
832 --title " Create a SliTaz USB key " \
|
pascal@17635
|
833 --yes-label "Continue" --yesno \
|
pascal@17635
|
834 "\nUnlike a hard drive install, the filesystem is kept in a compressed
|
pascal@17635
|
835 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
|
pascal@17635
|
836 This should increase responsiveness, protect the filesystem against
|
pascal@17635
|
837 accidental corruption and reduce read/writes to the USB drive.
|
pascal@17635
|
838 Once setup, the tazusb utility can rewrite the root filesystem
|
pascal@17635
|
839 with any changes you have made since booting up,
|
pascal@17635
|
840 giving the effective benefits of a hard drive install.\n\n
|
pascal@17635
|
841 /home is mounted on boot using the UUID of your particular flash drive.
|
pascal@17635
|
842 Unlike a device name, the UUID has the benefit of never changing from machine
|
pascal@17635
|
843 to machine.\n\n
|
pascal@17635
|
844 Please plug your USB stick in now.\n
|
pascal@17635
|
845 " 19 70
|
pascal@17635
|
846 [ $? -eq 0 ] || return
|
pascal@17635
|
847 usbdev || return
|
pascal@17635
|
848 exec 3>&1
|
pascal@17635
|
849 format=`$DIALOG --clear \
|
pascal@17635
|
850 --title " Select the filesystem " \
|
pascal@17635
|
851 --radiolist "\nPlease select the filesystem type to create.\n\n\
|
pascal@17635
|
852 The filesystem creation will erase all the data \
|
pascal@17635
|
853 in the USB key." 14 70 4 \
|
pascal@17635
|
854 "none" "Do not erase the USB key" on \
|
pascal@17635
|
855 "ext3" "Ext3 journaling filesystem" off \
|
pascal@17635
|
856 "ext2" "Ext2 filesystem" off \
|
pascal@17635
|
857 "fat32" "Windows FAT32 filesystem" off \
|
pascal@17635
|
858 2>&1 1>&3`
|
pascal@17635
|
859 retval=$?
|
pascal@17635
|
860 exec 3>&-
|
pascal@17635
|
861 [ $retval -eq 0 ] || return
|
pascal@17635
|
862 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
|
pascal@17635
|
863 tazusb gen-iso2usb $ISO $device
|
pascal@17635
|
864 }
|
pascal@17635
|
865
|
pascal@17635
|
866 dokexec()
|
pascal@17635
|
867 {
|
pascal@17659
|
868 kexec -l $file || return
|
pascal@17635
|
869 umount -d /media/cdrom
|
pascal@17635
|
870 kexec -e
|
pascal@17635
|
871 }
|
pascal@17635
|
872
|
pascal@17635
|
873 runmemtest()
|
pascal@17635
|
874 {
|
pascal@17635
|
875 gotcdfile 'memtest*' && dokexec
|
pascal@17635
|
876 }
|
pascal@17635
|
877
|
pascal@17635
|
878 runpxe()
|
pascal@17635
|
879 {
|
pascal@17635
|
880 gotcdfile '?pxe' && dokexec
|
pascal@17635
|
881 }
|
pascal@17635
|
882
|
pascal@17635
|
883 quit()
|
pascal@17635
|
884 {
|
pascal@17635
|
885 umount -d /media/cdrom
|
pascal@17635
|
886 exit
|
pascal@17635
|
887 }
|
pascal@17635
|
888
|
pascal@17635
|
889 ISO="$1"
|
pascal@17635
|
890 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
|
pascal@17635
|
891 mount -o loop,ro $ISO /media/cdrom
|
pascal@17635
|
892
|
pascal@17635
|
893 while true; do
|
pascal@17635
|
894 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
895 $DIALOG --clear \
|
pascal@17635
|
896 --title " SliTaz ISO tool " \
|
pascal@17635
|
897 --menu "" 23 70 17 \
|
pascal@17635
|
898 $(cdfile 'README*' "readme" "Show the README file") \
|
pascal@17635
|
899 $(gotisomd5 "isomd5" "Check the ISO image") \
|
pascal@17635
|
900 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
|
pascal@17635
|
901 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
|
pascal@17635
|
902 $(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \
|
pascal@17635
|
903 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
|
pascal@17635
|
904 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
|
pascal@17635
|
905 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
|
pascal@17635
|
906 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
|
pascal@17635
|
907 $(xfile tazusb "usbkey" "USB key read/write installation") \
|
pascal@17635
|
908 $(ishybrid "usbbootkey" "USB boot key (read only)") \
|
pascal@17635
|
909 "tazboot" "Get tazboot.exe Linux loader" \
|
pascal@17635
|
910 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
|
pascal@17635
|
911 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
|
pascal@17635
|
912 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
|
pascal@17635
|
913 $(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \
|
pascal@17635
|
914 $(cdexe '?pxe' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
|
pascal@17635
|
915 $(cdfilef '?pxe' "fdpxe" "Create a SliTaz Web boot floppy") \
|
pascal@17635
|
916 $(cdfilex '?pxe' "runpxe" "Start the SliTaz Web boot utility") \
|
pascal@17635
|
917 $(misspkg "missing" "Install packages to get more options") \
|
pascal@17635
|
918 "quit" "Quit this utility"
|
pascal@17635
|
919 EOT
|
pascal@17635
|
920 exec 3>&1
|
pascal@17635
|
921 value=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17635
|
922 retval=$?
|
pascal@17635
|
923 exec 3>&-
|
pascal@17635
|
924 rm -f /tmp/dialog$$
|
pascal@17635
|
925 [ $retval -eq 0 ] || continue
|
pascal@17635
|
926 $value
|
pascal@17635
|
927 done
|