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