rev |
line source |
pascal@13691
|
1 #!/bin/sh
|
pascal@13691
|
2
|
pascal@13691
|
3 DIALOG=dialog
|
pascal@13691
|
4
|
pascal@13691
|
5 get()
|
pascal@13691
|
6 {
|
pascal@13713
|
7 od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null ||
|
pascal@13713
|
8 dd if=$2 bs=1 skip=$1 count=${3:-2} 2> /dev/null | \
|
pascal@13713
|
9 hexdump -e "\"\" 1/${3:-2} \"%d\""
|
pascal@13691
|
10 }
|
pascal@13691
|
11
|
pascal@13691
|
12 getarg()
|
pascal@13691
|
13 {
|
pascal@13691
|
14 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline
|
pascal@13691
|
15 }
|
pascal@13691
|
16
|
pascal@13691
|
17 gettazboot()
|
pascal@13691
|
18 {
|
paul@13692
|
19 echo "Creating $(basename $1) ..."
|
pascal@13972
|
20 O=$(($(get 66 /mnt/$ISO) - 0xE0))
|
pascal@13972
|
21 L=$((0x8000 - $(get 24 /mnt/$ISO) - $O))
|
pascal@13691
|
22 S=$((32+$L))
|
pascal@13691
|
23 P=$((($S+511)/512))
|
pascal@13691
|
24 E=$((4096-(32*$P)))
|
pascal@13691
|
25 for i in 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
|
pascal@13691
|
26 -2 0 256 -16 28 0x6C53 0x5469 0x7A61; do
|
pascal@13691
|
27 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | \
|
pascal@13691
|
28 xargs echo -en
|
pascal@13691
|
29 done > $1
|
pascal@13691
|
30 dd bs=1 count=$L skip=$(echo $O) if=/mnt/$ISO >> $1 2> /dev/null
|
pascal@13691
|
31 }
|
pascal@13691
|
32
|
pascal@13691
|
33 checkmagic()
|
pascal@13691
|
34 {
|
pascal@13972
|
35 [ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ]
|
pascal@13691
|
36 }
|
pascal@13691
|
37
|
pascal@13691
|
38 getiso()
|
pascal@13691
|
39 {
|
pascal@13713
|
40 mkdir -p /media/cdrom
|
pascal@13691
|
41 blkid | while read dev info ; do
|
pascal@13713
|
42 mount ${dev%:} /mnt
|
pascal@13713
|
43 if checkmagic /mnt/$ISO; then
|
pascal@13713
|
44 mount -o loop,ro /mnt/$ISO /media/cdrom
|
pascal@13713
|
45 echo "Found $ISO on ${dev%:}"
|
pascal@13713
|
46 break
|
pascal@13713
|
47 fi
|
pascal@13713
|
48 umount /mnt
|
pascal@13691
|
49 done
|
pascal@13691
|
50 }
|
pascal@13691
|
51
|
pascal@13691
|
52 uncpio()
|
pascal@13691
|
53 {
|
pascal@13691
|
54 echo "Extracting $(basename $1) ..."
|
pascal@13699
|
55 case $(get 0 $1) in
|
pascal@13691
|
56 *35615) zcat $1 ;;
|
pascal@13691
|
57 *\ 93) unlzma -c $1 ;;
|
pascal@13691
|
58 *) cat $1 ;;
|
pascal@13691
|
59 esac | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
|
pascal@13691
|
60 }
|
pascal@13691
|
61
|
pascal@13691
|
62 getuuid()
|
pascal@13691
|
63 {
|
pascal@13691
|
64 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
|
pascal@13691
|
65 blkid | sed "/$dev:/!d;s/.*UUID=.\\([^ ]*\\)\".*/\\1/"
|
pascal@13691
|
66 }
|
pascal@13691
|
67
|
pascal@13691
|
68 mkinitrd()
|
pascal@13691
|
69 {
|
paul@13692
|
70 echo "Creating $(basename $1) ..."
|
pascal@13691
|
71 for i in bin lib dev proc tmp mnt etc ; do
|
pascal@13691
|
72 mkdir -p /tmp/fs/$i
|
pascal@13691
|
73 done
|
pascal@13691
|
74 for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/fuse \
|
pascal@13691
|
75 /dev/hd* /dev/sd* ; do
|
pascal@13691
|
76 cp -a $i /tmp/fs$i
|
pascal@13691
|
77 done
|
pascal@13713
|
78 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
|
pascal@13691
|
79 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
|
pascal@13691
|
80 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib
|
pascal@13691
|
81 cp $i /tmp/fs/bin
|
pascal@13691
|
82 done
|
pascal@13691
|
83 cp -a /lib/ld-* /tmp/fs/lib
|
pascal@13691
|
84 for i in $(busybox | sed '/Current/,$!d'); do
|
pascal@13691
|
85 ln -s busybox /tmp/fs/bin/${i%,}
|
pascal@13691
|
86 done
|
pascal@13691
|
87 ln -s /proc/mounts /tmp/fs/etc/mtab
|
pascal@13691
|
88 cat > /tmp/fs/init <<EOT
|
pascal@13691
|
89 #!/bin/sh
|
pascal@13691
|
90
|
pascal@13691
|
91 arg()
|
pascal@13691
|
92 {
|
pascal@13691
|
93 grep -q \$1 /proc/cmdline &&
|
pascal@13691
|
94 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
|
pascal@13691
|
95 echo "\$2 \$val"
|
pascal@13691
|
96 }
|
pascal@13691
|
97
|
pascal@13691
|
98 mount -t proc /proc /proc
|
pascal@13691
|
99 arg mount "Mount device"
|
pascal@13691
|
100 mount \$( (blkid /dev/?d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
|
pascal@13691
|
101 arg subroot "Change root to directory"
|
pascal@14247
|
102 mount.posixovl -F /mnt/\$val
|
pascal@13691
|
103 mount --bind /mnt /mnt/\$val/mnt/dos
|
pascal@13691
|
104 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
|
pascal@13691
|
105 umount /proc
|
pascal@13691
|
106 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
|
pascal@13691
|
107 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
|
pascal@13691
|
108 EOT
|
pascal@13691
|
109 chmod +x /tmp/fs/init
|
pascal@13691
|
110 ( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
|
pascal@13691
|
111 rm -rf /tmp/fs
|
pascal@13691
|
112 }
|
pascal@13691
|
113
|
pascal@13713
|
114 is_loram()
|
pascal@13713
|
115 {
|
pascal@13713
|
116 [ -s /lib/squashfs.ko* ]
|
pascal@13713
|
117 }
|
pascal@13713
|
118
|
pascal@13691
|
119 doinstall()
|
pascal@13691
|
120 {
|
pascal@13691
|
121 mkdir /mnt/slitaz
|
pascal@14247
|
122 mount.posixovl -F /mnt/slitaz || return
|
pascal@13691
|
123 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
|
pascal@13713
|
124 if [ -d /media/cdrom/fs ]; then
|
pascal@13713
|
125 cp -a /media/cdrom/fs/. /mnt/slitaz
|
pascal@13713
|
126 elif is_loram ; then
|
pascal@13713
|
127 for i in /media/cdrom/boot/rootfs?.* ; do
|
pascal@13713
|
128 [ -s $(basename $i) ] && continue
|
pascal@13713
|
129 cpio -i $i
|
pascal@13713
|
130 done
|
pascal@13713
|
131 for i in $(ls -r /media/cdrom/boot/rootfs*); do
|
pascal@13713
|
132 mount -o loop,ro $i /sqfs/mnt
|
pascal@13713
|
133 cp -a /sqfs/mnt/. /mnt/slitaz
|
pascal@13713
|
134 umount -d /sqfs/mnt
|
pascal@13713
|
135 done
|
pascal@13713
|
136 else
|
pascal@13713
|
137 for i in $(ls -r /media/cdrom/boot/rootfs*); do
|
pascal@13713
|
138 uncpio $i /mnt/slitaz
|
pascal@13713
|
139 done
|
pascal@13713
|
140 fi
|
pascal@13691
|
141 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
|
pascal@13691
|
142 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
|
pascal@13691
|
143 /media/cdrom/README /media/cdrom/boot/memtest* ; do
|
pascal@13691
|
144 [ -s $i ] && cp $i /mnt/slitaz/boot
|
pascal@13691
|
145 done
|
pascal@13691
|
146 umount -d /media/cdrom
|
pascal@13691
|
147 gettazboot /mnt/slitaz/boot/tazboot.exe
|
pascal@13691
|
148 mkinitrd /mnt/slitaz/boot/initrd
|
pascal@14247
|
149 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
|
pascal@13691
|
150 kernel=\\slitaz\\boot\\bzimage
|
pascal@13691
|
151 initrd=\\slitaz\\boot\\initrd
|
pascal@13691
|
152 rw root=/dev/null mount=$(getuuid) subroot=slitaz autologin
|
pascal@13691
|
153 EOT
|
pascal@13691
|
154 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
|
pascal@14247
|
155 /mnt/slitaz/boot/README
|
pascal@13691
|
156 [ -x /mnt/slitaz/usr/sbin/mount.posixovl ] ||
|
pascal@13713
|
157 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
|
pascal@14247
|
158 ! grep -qs tazboot /mnt/boot.ini && unix2dos >> /mnt/boot.ini <<EOT
|
pascal@13691
|
159 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
|
pascal@13691
|
160 EOT
|
pascal@13691
|
161 grep -qs menuitem /mnt/config.sys && !grep -q tazboot /mnt/config.sys &&
|
pascal@13691
|
162 sed -i 's/menudefault=/menuitem=slitaz,SliTaz\n&/' /mnt/config.sys &&
|
pascal@13691
|
163 cat >> /mnt/config.sys <<EOT
|
pascal@13691
|
164 [slitaz]
|
pascal@13691
|
165 device=\\slitaz\\boot\\tazboot.exe
|
pascal@13691
|
166 EOT
|
pascal@14247
|
167 unix2dos /mnt/config.sys
|
pascal@13691
|
168 }
|
pascal@13691
|
169
|
pascal@13691
|
170 install()
|
pascal@13691
|
171 {
|
pascal@13691
|
172 $DIALOG --clear \
|
pascal@13691
|
173 --title " SliTaz UMSDOS like installation " \
|
pascal@13691
|
174 --yes-label "Install" --yesno \
|
pascal@13691
|
175 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
pascal@13691
|
176 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
|
paul@13692
|
177 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@13691
|
178 To uninstall SliTaz, you have only to remove this directory.
|
pascal@13691
|
179 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@13697
|
180 To do a traditional installation with disk partitioning,
|
pascal@13691
|
181 start SliTaz Live with 'SliTaz RAM boot' menu.\n
|
pascal@13691
|
182 " 16 70
|
pascal@13713
|
183 [ $? -eq 0 -a -n "$(which mount.posixovl)" ] || return
|
pascal@13691
|
184 doinstall
|
pascal@13691
|
185 umount /proc
|
pascal@13691
|
186 exec chroot /mnt/slitaz /sbin/init
|
pascal@13691
|
187 }
|
pascal@13691
|
188
|
pascal@13691
|
189 tazboot()
|
pascal@13691
|
190 {
|
pascal@13691
|
191 $DIALOG --clear \
|
pascal@13691
|
192 --title " SliTaz bootloader for DOS " \
|
pascal@13691
|
193 --yes-label "Install" --yesno \
|
paul@13692
|
194 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
|
pascal@13697
|
195 a bzImage linux kernel, multiple initramfs, a kernel command line and
|
paul@13692
|
196 an ISO image file loopback (retrieves files from an ISO file).\n\n
|
pascal@13691
|
197 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
|
pascal@13691
|
198 [initrd=<rootfs>[,<rootfs2>...]] [iso=<isofile>] cmdline args ...]\n\n
|
paul@13692
|
199 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
|
pascal@13691
|
200 Examples for tazboot.cmd:\n\n\
|
pascal@13691
|
201 iso=\\isos\\slitaz-4.0.iso\n\
|
pascal@13691
|
202 kernel=boot/bzImage\n\
|
pascal@13691
|
203 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
|
pascal@13691
|
204 rw root=/dev/null autologin\n\n\
|
pascal@13691
|
205 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
|
pascal@13691
|
206 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n
|
pascal@13691
|
207 " 24 78
|
pascal@13691
|
208 [ $? -eq 0 ] || return
|
pascal@13691
|
209 gettazboot /mnt/tazboot.exe
|
pascal@13691
|
210 }
|
pascal@13691
|
211
|
pascal@13697
|
212 md5()
|
pascal@13697
|
213 {
|
pascal@13713
|
214 echo "Checking files..."
|
pascal@13713
|
215 ( cd /media/cdrom ; md5sum -c md5sum ) > /tmp/data
|
pascal@13697
|
216 $DIALOG --clear \
|
pascal@13697
|
217 --title " Checked files " \
|
pascal@13697
|
218 --textbox /tmp/data 24 78
|
pascal@13697
|
219 rm -f /tmp/data
|
pascal@13697
|
220 }
|
pascal@13697
|
221
|
pascal@13697
|
222 readme()
|
pascal@13697
|
223 {
|
pascal@13697
|
224 $DIALOG --clear \
|
pascal@13697
|
225 --title " Readme " \
|
pascal@13697
|
226 --textbox /media/cdrom/README 24 78
|
pascal@13697
|
227 }
|
pascal@13697
|
228
|
pascal@13697
|
229 bootlog()
|
pascal@13697
|
230 {
|
pascal@13697
|
231 $DIALOG --clear \
|
pascal@13697
|
232 --title " Linux boot messages " \
|
pascal@13697
|
233 --textbox /tmp/dmesg 24 78
|
pascal@13697
|
234 }
|
pascal@13697
|
235
|
pascal@13697
|
236 memtest()
|
pascal@13697
|
237 {
|
pascal@13697
|
238 $DIALOG --clear \
|
pascal@13697
|
239 --title " Memtest86 " \
|
pascal@13697
|
240 --yes-label "Install" --yesno \
|
pascal@13697
|
241 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@13697
|
242 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@13697
|
243 miss many of the failures that are detected by Memtest86.\n
|
pascal@13697
|
244 " 12 70
|
pascal@13697
|
245 [ $? -eq 0 ] || return
|
pascal@13697
|
246 cp /media/cdrom/boot/memtest /mnt
|
pascal@13697
|
247 }
|
pascal@13697
|
248
|
pascal@13697
|
249 fdmemtest()
|
pascal@13697
|
250 {
|
pascal@13697
|
251 $DIALOG --clear \
|
pascal@13697
|
252 --title " Create a Memtest86 boot floppy " \
|
pascal@13697
|
253 --yes-label "Create floppy" --yesno \
|
pascal@13697
|
254 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@13697
|
255 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@13697
|
256 miss many of the failures that are detected by Memtest86.\n\n
|
pascal@13697
|
257 Please insert a blank disk in floppy drive.\n
|
pascal@13697
|
258 " 12 70
|
pascal@13697
|
259 [ $? -eq 0 ] || return
|
pascal@13697
|
260 dd if=/media/cdrom/boot/memtest of=/dev/fd0
|
pascal@13697
|
261 }
|
pascal@13697
|
262
|
pascal@13697
|
263 gpxe()
|
pascal@13697
|
264 {
|
pascal@13697
|
265 $DIALOG --clear \
|
pascal@13697
|
266 --title " SliTaz Web boot " \
|
pascal@13697
|
267 --yes-label "Install" --yesno \
|
pascal@13697
|
268 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@13697
|
269 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@13697
|
270 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@13697
|
271 from the Web using PXE and HTTP protocols.\n
|
pascal@13697
|
272 " 12 70
|
pascal@13697
|
273 [ $? -eq 0 ] || return
|
pascal@13697
|
274 cp /media/cdrom/boot/gpxe /mnt
|
pascal@13697
|
275 }
|
pascal@13697
|
276
|
pascal@13697
|
277 fdgpxe()
|
pascal@13697
|
278 {
|
pascal@13697
|
279 $DIALOG --clear \
|
pascal@13697
|
280 --title " Create a SliTaz Web boot floppy " \
|
pascal@13697
|
281 --yes-label "Create floppy" --yesno \
|
pascal@13697
|
282 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@13697
|
283 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@13697
|
284 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@13697
|
285 from the Web using PXE and HTTP protocols.\n\n
|
pascal@13697
|
286 Please insert a blank disk in floppy drive.\n
|
pascal@13697
|
287 " 12 70
|
pascal@13697
|
288 [ $? -eq 0 ] || return
|
pascal@13697
|
289 dd if=/media/cdrom/boot/gpxe of=/dev/fd0
|
pascal@13697
|
290 }
|
pascal@13697
|
291
|
pascal@13697
|
292 cdfile()
|
pascal@13697
|
293 {
|
pascal@13697
|
294 [ -s /media/cdrom/$1 ] && echo -en "$2 ${3// /.}"
|
pascal@13697
|
295 }
|
pascal@13697
|
296
|
pascal@14257
|
297 fdbootstrap()
|
pascal@14257
|
298 {
|
pascal@14257
|
299 sz=$(echo $(od -j 28 -N 1 -t u1 -An /mnt/$ISO))
|
pascal@14257
|
300 if [ 0$sz -eq 0 ]; then
|
pascal@14257
|
301 $DIALOG --clear \
|
pascal@14257
|
302 --title " No floppy bootstrap available " \
|
pascal@14257
|
303 --msgbox \
|
pascal@14257
|
304 "\nThe floppy bootstrap code is not available in the ISO file.\n\n
|
pascal@14257
|
305 Can't create the floppy.\n
|
pascal@14257
|
306 " 9 70
|
pascal@14257
|
307 else
|
pascal@14257
|
308 $DIALOG --clear \
|
pascal@14257
|
309 --title " Create a floppy bootstrap " \
|
pascal@14257
|
310 --yes-label "Continue" --yesno \
|
paul@14263
|
311 "\nThe floppy will install a driver to access the ISO file
|
pascal@14257
|
312 on your hard disk and will emulate a CD-ROM during the boot process.\n\n
|
pascal@14257
|
313 Please insert a floppy in drive now.\n
|
pascal@14257
|
314 " 10 70
|
pascal@14257
|
315 [ $? -eq 0 ] || return
|
pascal@14257
|
316 dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$(($sz * 512)) \
|
pascal@14257
|
317 skip=$(( $(od -j 60 -N 4 -t u4 -An) - ($sz * 512) ))
|
pascal@14257
|
318 echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1
|
pascal@14257
|
319 fi
|
pascal@14257
|
320 }
|
pascal@14257
|
321
|
pascal@14257
|
322 usbdev()
|
pascal@14257
|
323 {
|
pascal@14257
|
324 sleep 5
|
pascal@14257
|
325 DEV="$(grep -l 1 /sys/block/*/removable | \
|
pascal@14257
|
326 sed 's|/sys/block/\(.*\)/removable|\1|')"
|
pascal@14257
|
327 [ -n "$DEV" ] || return
|
pascal@14257
|
328 exec 3>&1
|
pascal@14257
|
329 device=`$DIALOG --clear \
|
pascal@14257
|
330 --title " Select your USB key " \
|
pascal@14257
|
331 --menu "\nPlease select the USB key according to its known size.\n\n" \
|
pascal@14257
|
332 14 70 4 \
|
pascal@14257
|
333 $(for i in $DEV ; do
|
pascal@14257
|
334 echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB"
|
pascal@14257
|
335 done) \
|
pascal@14257
|
336 2>&1 1>&3`
|
pascal@14257
|
337 retval=$?
|
pascal@14257
|
338 exec 3>&-
|
pascal@14257
|
339 [ $retval -eq 0 ]
|
pascal@14257
|
340 }
|
pascal@14257
|
341
|
pascal@14257
|
342 usbbootkey()
|
pascal@14257
|
343 {
|
pascal@14257
|
344 $DIALOG --clear \
|
pascal@14257
|
345 --title " Create a USB boot key " \
|
pascal@14257
|
346 --yes-label "Continue" --yesno \
|
pascal@14257
|
347 "\nThe USB key will be used like a CD-ROM. You will not be able to write
|
pascal@14257
|
348 any data on it.\n\n
|
pascal@14257
|
349 You should choose 'USB key read/write installation' to be
|
pascal@14257
|
350 able to save the package updates or your own configuration and data files.\n\n
|
pascal@14257
|
351 Please plug your USB stick in now.\n
|
pascal@14257
|
352 " 13 70
|
pascal@14257
|
353 [ $? -eq 0 ] || return
|
pascal@14257
|
354 usbdev || return
|
pascal@14257
|
355 dd if=/mnt/$ISO of=$device
|
pascal@14261
|
356 if [ $(get 0 /mnt/$ISO) -eq 23117 ]; then # iso2exe ?
|
pascal@14261
|
357 LOC=$(get 69 /mnt/$ISO 1)
|
pascal@14261
|
358 # move isohybrid boot sector (partitionable)
|
pascal@14261
|
359 dd if=/mnt/$ISO bs=512 count=1 skip=$LOC of=$device conv=notrunc
|
pascal@14261
|
360 # move tazlito data (backward compatibility)
|
pascal@14261
|
361 dd if=/mnt/$ISO bs=512 count=20 skip=$(($LOC+1)) of=$device seek=2 conv=notrunc
|
pascal@14261
|
362 fi
|
pascal@14257
|
363 }
|
pascal@14257
|
364
|
pascal@13697
|
365 usbkey()
|
pascal@13697
|
366 {
|
pascal@13697
|
367 $DIALOG --clear \
|
pascal@13697
|
368 --title " Create a SliTaz USB key " \
|
pascal@13697
|
369 --yes-label "Continue" --yesno \
|
pascal@13697
|
370 "\nUnlike a hard drive install, the filesystem is kept in a compressed
|
pascal@13697
|
371 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
|
pascal@13697
|
372 This should increase responsiveness, protect the filesystem against
|
pascal@13697
|
373 accidental corruption and reduce read/writes to the USB drive.
|
pascal@13697
|
374 Once setup, the tazusb utility can rewrite the root filesystem
|
pascal@13697
|
375 with any changes you have made since booting up,
|
pascal@13697
|
376 giving the effective benefits of a hard drive install.\n\n
|
pascal@13697
|
377 /home is mounted on boot using the UUID of your particular flash drive.
|
pascal@13697
|
378 Unlike a device name, the UUID has the benefit of never changing from machine
|
pascal@13697
|
379 to machine.\n\n
|
pascal@13697
|
380 Please plug your USB stick in now.\n
|
pascal@14257
|
381 " 19 70
|
pascal@14247
|
382 [ $? -eq 0 -a -n "$(which tazusb)" ] || return
|
pascal@14257
|
383 usbdev || return
|
pascal@13697
|
384 exec 3>&1
|
pascal@13697
|
385 format=`$DIALOG --clear \
|
pascal@13697
|
386 --title " Select the filesystem " \
|
pascal@13733
|
387 --radiolist "\nPlease select the filesystem type to create.\n\n\
|
paul@13698
|
388 The filesystem creation will erase all the data \
|
pascal@13699
|
389 in the USB key." 14 70 4 \
|
pascal@13733
|
390 "none" "Do not erase the USB key" on \
|
pascal@13733
|
391 "ext3" "Ext3 journaling filesystem" off \
|
pascal@13733
|
392 "ext2" "Ext2 filesystem" off \
|
pascal@13733
|
393 "fat32" "Windows FAT32 filesystem" off \
|
pascal@13697
|
394 2>&1 1>&3`
|
pascal@13697
|
395 retval=$?
|
pascal@13697
|
396 exec 3>&-
|
pascal@14257
|
397 [ $retval -eq 0 ] || return
|
pascal@13697
|
398 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
|
pascal@13697
|
399 tazusb gen-iso2usb /mnt/$ISO $device
|
pascal@13697
|
400 }
|
pascal@13697
|
401
|
pascal@13713
|
402 mount_loram()
|
pascal@13713
|
403 {
|
pascal@13713
|
404 is_loram || return
|
pascal@13713
|
405 insmod /lib/squashfs.ko* 2> /dev/null
|
pascal@13713
|
406 if [ -d /media/cdrom/fs ]; then
|
pascal@13713
|
407 ln -s /media/cdrom/fs /sqfs
|
pascal@13713
|
408 else
|
pascal@13713
|
409 mkdir /sqfs
|
pascal@13713
|
410 mount -o loop,ro -t squashfs /rootfs*.gz /sqfs
|
pascal@13713
|
411 fi
|
pascal@13713
|
412 ln -s /sqfs/lib/* lib
|
pascal@13713
|
413 ln -s /sqfs/usr /sqfs/var /
|
pascal@13713
|
414 for i in dmesg basename tr od reboot poweroff getty sync ; do
|
pascal@13713
|
415 ln -s /sqfs/bin/busybox /bin/$i
|
pascal@13713
|
416 done
|
pascal@13713
|
417 }
|
pascal@13713
|
418
|
pascal@13713
|
419 umount_loram()
|
pascal@13713
|
420 {
|
pascal@13713
|
421 is_loram || return
|
pascal@13713
|
422 rm /var /usr
|
pascal@13713
|
423 umount -d /sqfs
|
pascal@13713
|
424 rmdir /sqfs
|
pascal@13713
|
425 }
|
pascal@13713
|
426
|
pascal@13691
|
427 text()
|
pascal@13691
|
428 {
|
pascal@13713
|
429 umount_loram
|
pascal@13691
|
430 umount -d /media/cdrom
|
pascal@13691
|
431 umount /mnt
|
pascal@13691
|
432 umount /proc
|
pascal@13691
|
433 exec /init
|
pascal@13691
|
434 }
|
pascal@13691
|
435
|
pascal@13691
|
436 live()
|
pascal@13691
|
437 {
|
pascal@13691
|
438 n=0
|
pascal@13691
|
439 for i in $(ls -r /media/cdrom/boot/rootfs*); do
|
pascal@13691
|
440 [ $((n++)) -eq 0 ] || uncpio $i
|
pascal@13691
|
441 done
|
pascal@13691
|
442 text
|
pascal@13691
|
443 }
|
pascal@13691
|
444
|
pascal@13713
|
445 restart()
|
pascal@13691
|
446 {
|
pascal@13713
|
447 sync
|
pascal@13713
|
448 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
|
pascal@13713
|
449 reboot -f
|
pascal@13691
|
450 }
|
pascal@13691
|
451
|
pascal@13713
|
452 stop()
|
pascal@13691
|
453 {
|
pascal@13713
|
454 sync
|
pascal@13713
|
455 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
|
pascal@13713
|
456 poweroff -f
|
pascal@13691
|
457 }
|
pascal@13691
|
458
|
pascal@13697
|
459 shell()
|
pascal@13697
|
460 {
|
pascal@13713
|
461 getty -n -l /bin/ash 38400 tty1 || sh
|
pascal@13697
|
462 }
|
pascal@13697
|
463
|
pascal@14247
|
464 BIN=bin/mount.posixovl
|
pascal@14247
|
465 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \
|
pascal@14247
|
466 /usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN
|
pascal@13691
|
467 mount -t proc /proc /proc
|
pascal@13691
|
468 ISO="$(getarg iso | sed 's/.://;s|\\|/|g')"
|
pascal@13691
|
469 getiso
|
pascal@13713
|
470 mount_loram
|
pascal@13691
|
471 case "$(basename $ISO | tr [A-Z] [a-z])$(getarg mode)" in
|
pascal@13691
|
472 *install*) install ;;
|
pascal@13691
|
473 *live*) live ;;
|
pascal@13691
|
474 *text*) text ;;
|
pascal@13691
|
475 esac
|
pascal@14247
|
476 which $DIALOG || live
|
pascal@13713
|
477 dmesg > /tmp/dmesg
|
pascal@13691
|
478
|
pascal@13691
|
479 while true; do
|
pascal@13691
|
480 exec 3>&1
|
pascal@13691
|
481 value=`$DIALOG --clear \
|
pascal@13691
|
482 --title " Welcome to SliTaz " \
|
pascal@14257
|
483 --menu "\nPlease select" 19 70 11 \
|
pascal@13697
|
484 "live" "SliTaz RAM boot" \
|
pascal@13697
|
485 "text" "SliTaz RAM boot (text mode only)" \
|
pascal@13697
|
486 $(cdfile README "readme" "Show the README file") \
|
pascal@13697
|
487 $(cdfile md5sum "md5" "Check ISO files") \
|
pascal@13697
|
488 "install" "Hard disk installation" \
|
pascal@14257
|
489 "usbkey" "USB key read/write installation" \
|
pascal@14257
|
490 "usbbootkey" "USB boot key (read only)" \
|
pascal@14257
|
491 "fdbootstrap" "Floppy bootstrap" \
|
pascal@13697
|
492 "tazboot" "Get tazboot.exe Linux loader" \
|
pascal@13697
|
493 $(cdfile Xboot/memtest "memtest" "Get Memtest86") \
|
pascal@13697
|
494 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \
|
pascal@13697
|
495 $(cdfile Xboot/gpxe "gpxe" "Get SliTaz Web boot utility") \
|
pascal@13697
|
496 $(cdfile boot/gpxe "fdgpxe" "Create a SliTaz Web boot floppy") \
|
pascal@13713
|
497 "restart" "Restart the computer" \
|
pascal@13713
|
498 "stop" "Power off" \
|
pascal@13697
|
499 "bootlog" "Linux boot messages" \
|
pascal@13697
|
500 "shell" "Shell prompt" \
|
pascal@13691
|
501 2>&1 1>&3`
|
pascal@13691
|
502 retval=$?
|
pascal@13691
|
503 exec 3>&-
|
pascal@13691
|
504 [ $retval -eq 0 ] || continue
|
pascal@13691
|
505 $value
|
pascal@13691
|
506 done
|