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@14264
|
8 hexdump -s $1 -n ${3:-2} -e "\"\" 1/${3:-2} \"%d\"" $2
|
pascal@13691
|
9 }
|
pascal@13691
|
10
|
pascal@13691
|
11 getarg()
|
pascal@13691
|
12 {
|
pascal@13691
|
13 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline
|
pascal@13691
|
14 }
|
pascal@13691
|
15
|
pascal@16041
|
16 mount_proc()
|
pascal@16041
|
17 {
|
pascal@16041
|
18 mount -t proc /proc /proc
|
pascal@16041
|
19 mount -t sysfs /sys /sys
|
pascal@16041
|
20 udevd --daemon 2> /dev/null && udevadm trigger && sleep 5
|
pascal@16041
|
21 }
|
pascal@16041
|
22
|
pascal@16041
|
23 umount_proc()
|
pascal@16041
|
24 {
|
pascal@16041
|
25 killall udevd 2> /dev/null
|
pascal@16041
|
26 umount /sys/fs/fuse/connections 2> /dev/null
|
pascal@16041
|
27 umount /sys
|
pascal@16041
|
28 umount /proc
|
pascal@16041
|
29 }
|
pascal@16041
|
30
|
pascal@13691
|
31 gettazboot()
|
pascal@13691
|
32 {
|
paul@13692
|
33 echo "Creating $(basename $1) ..."
|
pascal@14271
|
34 O=$(($(get 66 /mnt/$ISO) - 0xC0))
|
pascal@14271
|
35 L=$((0x7EE0 - $(get 24 /mnt/$ISO) - $O))
|
pascal@13691
|
36 S=$((32+$L))
|
pascal@13691
|
37 P=$((($S+511)/512))
|
pascal@13691
|
38 E=$((4096-(32*$P)))
|
pascal@13691
|
39 for i in 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
|
pascal@13691
|
40 -2 0 256 -16 28 0x6C53 0x5469 0x7A61; do
|
pascal@13691
|
41 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | \
|
pascal@13691
|
42 xargs echo -en
|
pascal@13691
|
43 done > $1
|
pascal@13691
|
44 dd bs=1 count=$L skip=$(echo $O) if=/mnt/$ISO >> $1 2> /dev/null
|
pascal@13691
|
45 }
|
pascal@13691
|
46
|
pascal@13691
|
47 checkmagic()
|
pascal@13691
|
48 {
|
pascal@13972
|
49 [ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ]
|
pascal@13691
|
50 }
|
pascal@13691
|
51
|
pascal@13691
|
52 getiso()
|
pascal@13691
|
53 {
|
pascal@13713
|
54 mkdir -p /media/cdrom
|
pascal@13691
|
55 blkid | while read dev info ; do
|
pascal@13713
|
56 mount ${dev%:} /mnt
|
pascal@13713
|
57 if checkmagic /mnt/$ISO; then
|
pascal@13713
|
58 mount -o loop,ro /mnt/$ISO /media/cdrom
|
pascal@13713
|
59 echo "Found $ISO on ${dev%:}"
|
pascal@13713
|
60 break
|
pascal@13713
|
61 fi
|
pascal@13713
|
62 umount /mnt
|
pascal@13691
|
63 done
|
pascal@13691
|
64 }
|
pascal@13691
|
65
|
pascal@13691
|
66 uncpio()
|
pascal@13691
|
67 {
|
pascal@13691
|
68 echo "Extracting $(basename $1) ..."
|
pascal@13699
|
69 case $(get 0 $1) in
|
pascal@13691
|
70 *35615) zcat $1 ;;
|
pascal@13691
|
71 *\ 93) unlzma -c $1 ;;
|
pascal@13691
|
72 *) cat $1 ;;
|
pascal@13691
|
73 esac | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
|
pascal@13691
|
74 }
|
pascal@13691
|
75
|
pascal@13691
|
76 getuuid()
|
pascal@13691
|
77 {
|
pascal@13691
|
78 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
|
pascal@16041
|
79 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/"
|
pascal@13691
|
80 }
|
pascal@13691
|
81
|
pascal@16055
|
82 tazusbinitfs()
|
pascal@16055
|
83 {
|
pascal@16055
|
84 PAD=$(($(stat -c %s $1) % 4))
|
pascal@16055
|
85 [ $PAD -ne 0 ] && dd if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
|
pascal@16055
|
86 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home
|
pascal@16055
|
87 cp -a /etc/locale.conf /tmp/fs/etc 2> /dev/null
|
pascal@16055
|
88 cp -a /etc/keymap.conf /tmp/fs/etc 2> /dev/null
|
pascal@16055
|
89 sed 's/ .*//' /proc/modules | while read mod ; do
|
pascal@16055
|
90 find /lib/modules/ | grep $mod.ko | \
|
pascal@16055
|
91 sed 's|.*|cp & /tmp/fs/lib|' | sh
|
pascal@16055
|
92 done
|
pascal@16055
|
93 cat > /tmp/fs/init1 <<EOT
|
pascal@16055
|
94 #!/bin/sh
|
pascal@16055
|
95 sed -i 's|sbin/init|init2|' /init
|
pascal@16055
|
96 exec /init
|
pascal@16055
|
97 EOT
|
pascal@16055
|
98 cat > /tmp/fs/init2 <<EOT
|
pascal@16055
|
99 #!/bin/sh
|
pascal@16055
|
100
|
pascal@16055
|
101 mount -t proc /proc /proc
|
pascal@16055
|
102 grep -q debug /proc/cmdline && debug=true && set -x
|
pascal@16055
|
103 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@16055
|
104 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
|
pascal@16055
|
105 mount / -o remount,rw
|
pascal@16055
|
106 mkdir /mnt/dos
|
pascal@16055
|
107 rm -f /cmdline 2> /dev/null
|
pascal@16055
|
108 mount / -o remount,ro
|
pascal@16055
|
109 mnt=/mnt/dos/\${v#*/}
|
pascal@16055
|
110 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
|
pascal@16055
|
111 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
|
pascal@16055
|
112 mount \$dev /mnt/dos
|
pascal@16055
|
113 mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
|
pascal@16055
|
114 mount --bind \$mnt /home
|
pascal@16055
|
115 [ "\$debug" = "true" ] && sh
|
pascal@16055
|
116 umount /proc
|
pascal@16055
|
117 exec /sbin/init
|
pascal@16055
|
118 EOT
|
pascal@16055
|
119 chmod 755 /tmp/fs/init?
|
pascal@16055
|
120 cp -a /tmp/fs/* /
|
pascal@16055
|
121 ( cd /tmp/fs ; find * | cpio -o -H newc ) | gzip -9 >> $1
|
pascal@16055
|
122 }
|
pascal@16055
|
123
|
pascal@13691
|
124 mkinitrd()
|
pascal@13691
|
125 {
|
paul@13692
|
126 echo "Creating $(basename $1) ..."
|
pascal@13691
|
127 for i in bin lib dev proc tmp mnt etc ; do
|
pascal@13691
|
128 mkdir -p /tmp/fs/$i
|
pascal@13691
|
129 done
|
pascal@16041
|
130 for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/tty2 /dev/fuse \
|
pascal@13691
|
131 /dev/hd* /dev/sd* ; do
|
pascal@13691
|
132 cp -a $i /tmp/fs$i
|
pascal@13691
|
133 done
|
pascal@13713
|
134 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
|
pascal@13691
|
135 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
|
pascal@13691
|
136 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib
|
pascal@13691
|
137 cp $i /tmp/fs/bin
|
pascal@13691
|
138 done
|
pascal@13691
|
139 cp -a /lib/ld-* /tmp/fs/lib
|
pascal@13691
|
140 for i in $(busybox | sed '/Current/,$!d'); do
|
pascal@14271
|
141 [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,}
|
pascal@13691
|
142 done
|
pascal@13691
|
143 ln -s /proc/mounts /tmp/fs/etc/mtab
|
pascal@16041
|
144 sed 's/ .*//' /proc/modules | while read mod ; do
|
pascal@16041
|
145 find /lib/modules/ | grep $mod.ko | \
|
pascal@16041
|
146 sed 's|.*|cp & /tmp/fs/lib|' | sh
|
pascal@16041
|
147 done
|
pascal@13691
|
148 cat > /tmp/fs/init <<EOT
|
pascal@13691
|
149 #!/bin/sh
|
pascal@13691
|
150
|
pascal@13691
|
151 arg()
|
pascal@13691
|
152 {
|
pascal@13691
|
153 grep -q \$1 /proc/cmdline &&
|
pascal@13691
|
154 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
|
pascal@13691
|
155 echo "\$2 \$val"
|
pascal@13691
|
156 }
|
pascal@13691
|
157
|
pascal@13691
|
158 mount -t proc /proc /proc
|
pascal@16041
|
159 arg debug "shell" && debug=true && set -x
|
pascal@16055
|
160 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@13691
|
161 arg mount "Mount device"
|
pascal@16055
|
162 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
|
pascal@13691
|
163 arg subroot "Change root to directory"
|
pascal@16041
|
164 mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
|
pascal@13691
|
165 mount --bind /mnt /mnt/\$val/mnt/dos
|
pascal@13691
|
166 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
|
pascal@16041
|
167 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
|
pascal@16041
|
168 [ "$debug" = "true" ] && sh
|
pascal@13691
|
169 umount /proc
|
pascal@13691
|
170 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
|
pascal@13691
|
171 EOT
|
pascal@13691
|
172 chmod +x /tmp/fs/init
|
pascal@13691
|
173 ( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
|
pascal@13691
|
174 rm -rf /tmp/fs
|
pascal@13691
|
175 }
|
pascal@13691
|
176
|
pascal@13713
|
177 is_loram()
|
pascal@13713
|
178 {
|
pascal@13713
|
179 [ -s /lib/squashfs.ko* ]
|
pascal@13713
|
180 }
|
pascal@13713
|
181
|
pascal@16041
|
182 ls_r()
|
pascal@16041
|
183 {
|
pascal@16041
|
184 ls -r $@ 2> /dev/null || ls $@
|
pascal@16041
|
185 }
|
pascal@16041
|
186
|
pascal@13691
|
187 doinstall()
|
pascal@13691
|
188 {
|
pascal@14271
|
189 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
|
pascal@16041
|
190 if ! mount.posixovl -F /mnt/slitaz -- \
|
pascal@16041
|
191 -oallow_other -odefault_permissions -osuid; then
|
pascal@16041
|
192 echo "Can't install SliTaz. Abort."
|
pascal@16041
|
193 sleep 5
|
pascal@16041
|
194 return 1
|
pascal@16041
|
195 fi
|
pascal@16041
|
196 echo "Install root filesystem in /slitaz..."
|
pascal@14271
|
197 if [ -n "$1" ]; then
|
pascal@14271
|
198 if [ -d /media/cdrom/fs ]; then
|
pascal@14271
|
199 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
|
pascal@14271
|
200 else
|
pascal@16041
|
201 ls_r /media/cdrom/boot/rootfs* | xargs cat
|
pascal@14271
|
202 fi > /mnt/slitaz/boot/rootfs.gz
|
pascal@16055
|
203 tazusbinitfs /mnt/slitaz/boot/rootfs.gz
|
pascal@14271
|
204 initrd=rootfs.gz
|
pascal@16055
|
205 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
|
pascal@13713
|
206 else
|
pascal@14271
|
207 if [ -d /media/cdrom/fs ]; then
|
pascal@14271
|
208 cp -a /media/cdrom/fs/. /mnt/slitaz
|
pascal@14271
|
209 elif is_loram ; then
|
pascal@14271
|
210 for i in /media/cdrom/boot/rootfs?.* ; do
|
pascal@14271
|
211 [ -s $(basename $i) ] && continue
|
pascal@14271
|
212 cpio -i $i
|
pascal@14271
|
213 done
|
pascal@16041
|
214 for i in $(ls_r /media/cdrom/boot/rootfs*); do
|
pascal@14271
|
215 mount -o loop,ro $i /sqfs/mnt
|
pascal@14271
|
216 cp -a /sqfs/mnt/. /mnt/slitaz
|
pascal@14271
|
217 umount -d /sqfs/mnt
|
pascal@14271
|
218 done
|
pascal@14271
|
219 else
|
pascal@16041
|
220 for i in $(ls_r /media/cdrom/boot/rootfs*); do
|
pascal@14271
|
221 uncpio $i /mnt/slitaz
|
pascal@14271
|
222 done
|
pascal@14271
|
223 fi
|
pascal@16055
|
224 cp -a /etc/locale.conf /tmp/slitaz/etc 2> /dev/null
|
pascal@16055
|
225 cp -a /etc/keymap.conf /tmp/slitaz/etc 2> /dev/null
|
pascal@14271
|
226 mkinitrd /mnt/slitaz/boot/initrd
|
pascal@14271
|
227 initrd=initrd
|
pascal@14271
|
228 extraargs="mount=$(getuuid) subroot=slitaz"
|
pascal@13713
|
229 fi
|
pascal@14271
|
230 echo "Install boot files..."
|
pascal@13691
|
231 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
|
pascal@13691
|
232 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
|
pascal@13691
|
233 /media/cdrom/README /media/cdrom/boot/memtest* ; do
|
pascal@13691
|
234 [ -s $i ] && cp $i /mnt/slitaz/boot
|
pascal@13691
|
235 done
|
pascal@16047
|
236 for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe* ; do
|
pascal@16047
|
237 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
|
pascal@16047
|
238 mv $i $i.exe
|
pascal@16047
|
239 done
|
pascal@13691
|
240 gettazboot /mnt/slitaz/boot/tazboot.exe
|
pascal@14247
|
241 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
|
pascal@16041
|
242 kernel=/slitaz/boot/bzimage
|
pascal@16041
|
243 initrd=/slitaz/boot/$initrd
|
pascal@14271
|
244 rw root=/dev/null $extraargs autologin
|
pascal@13691
|
245 EOT
|
pascal@13691
|
246 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
|
pascal@14247
|
247 /mnt/slitaz/boot/README
|
pascal@14271
|
248 [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
|
pascal@13713
|
249 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
|
pascal@16041
|
250 false &&
|
pascal@16041
|
251 ! grep -qs tazboot /mnt/boot.ini && echo "Update boot.ini ..." &&
|
pascal@16041
|
252 unix2dos >> /mnt/boot.ini <<EOT
|
pascal@13691
|
253 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
|
pascal@13691
|
254 EOT
|
pascal@16073
|
255 false &&
|
pascal@16073
|
256 grep -qis menuitem /mnt/config.sys && ! grep -qi tazboot /mnt/config.sys &&
|
pascal@16041
|
257 echo "Update config.sys ..." &&
|
pascal@16073
|
258 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' /mnt/config.sys &&
|
pascal@16073
|
259 unix2dos >> /mnt/config.sys <<EOT
|
pascal@16073
|
260 [SLITAZ]
|
pascal@16073
|
261 install=\\slitaz\\boot\\tazboot.exe
|
pascal@13691
|
262 EOT
|
pascal@16041
|
263 return 0
|
pascal@13691
|
264 }
|
pascal@13691
|
265
|
pascal@13691
|
266 install()
|
pascal@13691
|
267 {
|
pascal@13691
|
268 $DIALOG --clear \
|
pascal@14271
|
269 --title " SliTaz UMSDOS way installation " \
|
pascal@13691
|
270 --yes-label "Install" --yesno \
|
pascal@13691
|
271 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
pascal@13691
|
272 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
|
paul@13692
|
273 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@13691
|
274 To uninstall SliTaz, you have only to remove this directory.
|
pascal@13691
|
275 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@14271
|
276 SliTaz may run slowly on 'UMSDOS way' installation due to the
|
paul@14320
|
277 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
|
pascal@13697
|
278 To do a traditional installation with disk partitioning,
|
pascal@13691
|
279 start SliTaz Live with 'SliTaz RAM boot' menu.\n
|
pascal@14271
|
280 " 19 70
|
pascal@14271
|
281 [ $? -eq 0 ] || return
|
pascal@16041
|
282 doinstall || return
|
pascal@16041
|
283 [ -x /mnt/slitaz/sbin/init ] || return
|
pascal@14271
|
284 umount -d /media/cdrom
|
pascal@16041
|
285 umount_proc
|
pascal@13691
|
286 exec chroot /mnt/slitaz /sbin/init
|
pascal@13691
|
287 }
|
pascal@13691
|
288
|
pascal@14271
|
289 installtaz()
|
pascal@14271
|
290 {
|
pascal@14271
|
291 $DIALOG --clear \
|
pascal@14271
|
292 --title " SliTaz TAZUSB way installation " \
|
pascal@14271
|
293 --yes-label "Install" --yesno \
|
pascal@14271
|
294 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
pascal@14271
|
295 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
|
pascal@14271
|
296 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@14271
|
297 To uninstall SliTaz, you have only to remove this directory.
|
pascal@14271
|
298 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@14271
|
299 The filesystem is loaded entirely into memory upon boot to
|
pascal@14271
|
300 increase responsiveness. Only /home lands on hard disk.\n\n
|
pascal@14271
|
301 To do a traditional installation with disk partitioning,
|
pascal@14271
|
302 start SliTaz Live with 'SliTaz RAM boot' menu.\n
|
pascal@14271
|
303 " 19 70
|
pascal@14271
|
304 [ $? -eq 0 ] || return
|
pascal@16041
|
305 doinstall tazusblike || return
|
pascal@14271
|
306 if [ -d /media/cdrom/fs ]; then
|
pascal@16055
|
307 cp -a /media/cdrom/fs/. /
|
pascal@14271
|
308 else
|
pascal@16041
|
309 for i in $(ls_r /media/cdrom/boot/rootfs*); do
|
pascal@16055
|
310 unlzma < $i | (cd / ; cpio -idmu )
|
pascal@14271
|
311 done
|
pascal@14271
|
312 fi
|
pascal@16055
|
313 cp /tmp/fs/etc/* /etc
|
pascal@16055
|
314 echo "/home=$(getuuid)/slitaz" > /cmdline
|
pascal@16055
|
315 [ -x /init1 ] || return
|
pascal@14271
|
316 umount -d /media/cdrom
|
pascal@16055
|
317 umount /mnt/slitaz
|
pascal@16073
|
318 rm -f /dev/cdrom
|
pascal@16055
|
319 umount /mnt
|
pascal@16055
|
320 mkdir /mnt/dos
|
pascal@16041
|
321 umount_proc
|
pascal@16055
|
322 exec /init1
|
pascal@14271
|
323 }
|
pascal@14271
|
324
|
pascal@13691
|
325 tazboot()
|
pascal@13691
|
326 {
|
pascal@13691
|
327 $DIALOG --clear \
|
pascal@13691
|
328 --title " SliTaz bootloader for DOS " \
|
pascal@13691
|
329 --yes-label "Install" --yesno \
|
paul@13692
|
330 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
|
pascal@13697
|
331 a bzImage linux kernel, multiple initramfs, a kernel command line and
|
paul@13692
|
332 an ISO image file loopback (retrieves files from an ISO file).\n\n
|
pascal@13691
|
333 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
|
pascal@13691
|
334 [initrd=<rootfs>[,<rootfs2>...]] [iso=<isofile>] cmdline args ...]\n\n
|
paul@13692
|
335 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
|
pascal@13691
|
336 Examples for tazboot.cmd:\n\n\
|
pascal@13691
|
337 iso=\\isos\\slitaz-4.0.iso\n\
|
pascal@13691
|
338 kernel=boot/bzImage\n\
|
pascal@13691
|
339 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
|
pascal@13691
|
340 rw root=/dev/null autologin\n\n\
|
pascal@13691
|
341 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
|
pascal@13691
|
342 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n
|
pascal@13691
|
343 " 24 78
|
pascal@13691
|
344 [ $? -eq 0 ] || return
|
pascal@13691
|
345 gettazboot /mnt/tazboot.exe
|
pascal@13691
|
346 }
|
pascal@13691
|
347
|
pascal@13697
|
348 md5()
|
pascal@13697
|
349 {
|
pascal@13713
|
350 echo "Checking files..."
|
pascal@13713
|
351 ( cd /media/cdrom ; md5sum -c md5sum ) > /tmp/data
|
pascal@13697
|
352 $DIALOG --clear \
|
pascal@13697
|
353 --title " Checked files " \
|
pascal@13697
|
354 --textbox /tmp/data 24 78
|
pascal@13697
|
355 rm -f /tmp/data
|
pascal@13697
|
356 }
|
pascal@13697
|
357
|
pascal@13697
|
358 readme()
|
pascal@13697
|
359 {
|
pascal@13697
|
360 $DIALOG --clear \
|
pascal@13697
|
361 --title " Readme " \
|
pascal@13697
|
362 --textbox /media/cdrom/README 24 78
|
pascal@13697
|
363 }
|
pascal@13697
|
364
|
pascal@13697
|
365 bootlog()
|
pascal@13697
|
366 {
|
pascal@13697
|
367 $DIALOG --clear \
|
pascal@13697
|
368 --title " Linux boot messages " \
|
pascal@13697
|
369 --textbox /tmp/dmesg 24 78
|
pascal@13697
|
370 }
|
pascal@13697
|
371
|
pascal@13697
|
372 memtest()
|
pascal@13697
|
373 {
|
pascal@13697
|
374 $DIALOG --clear \
|
pascal@13697
|
375 --title " Memtest86 " \
|
pascal@13697
|
376 --yes-label "Install" --yesno \
|
pascal@13697
|
377 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@13697
|
378 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@13697
|
379 miss many of the failures that are detected by Memtest86.\n
|
pascal@13697
|
380 " 12 70
|
pascal@13697
|
381 [ $? -eq 0 ] || return
|
pascal@16012
|
382 cp /media/cdrom/boot/memtest /mnt/memtest.exe
|
pascal@13697
|
383 }
|
pascal@13697
|
384
|
pascal@13697
|
385 fdmemtest()
|
pascal@13697
|
386 {
|
pascal@13697
|
387 $DIALOG --clear \
|
pascal@13697
|
388 --title " Create a Memtest86 boot floppy " \
|
pascal@13697
|
389 --yes-label "Create floppy" --yesno \
|
pascal@13697
|
390 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@13697
|
391 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@13697
|
392 miss many of the failures that are detected by Memtest86.\n\n
|
pascal@13697
|
393 Please insert a blank disk in floppy drive.\n
|
pascal@13697
|
394 " 12 70
|
pascal@13697
|
395 [ $? -eq 0 ] || return
|
pascal@13697
|
396 dd if=/media/cdrom/boot/memtest of=/dev/fd0
|
pascal@13697
|
397 }
|
pascal@13697
|
398
|
pascal@16013
|
399 pxe()
|
pascal@13697
|
400 {
|
pascal@13697
|
401 $DIALOG --clear \
|
pascal@13697
|
402 --title " SliTaz Web boot " \
|
pascal@13697
|
403 --yes-label "Install" --yesno \
|
pascal@13697
|
404 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@13697
|
405 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@13697
|
406 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@13697
|
407 from the Web using PXE and HTTP protocols.\n
|
pascal@13697
|
408 " 12 70
|
pascal@13697
|
409 [ $? -eq 0 ] || return
|
pascal@16012
|
410 pxe=$(ls /media/cdrom/boot/?pxe)
|
pascal@16012
|
411 cp $pxe /mnt/$(basename $pxe).exe
|
pascal@13697
|
412 }
|
pascal@13697
|
413
|
pascal@16013
|
414 fdpxe()
|
pascal@13697
|
415 {
|
pascal@13697
|
416 $DIALOG --clear \
|
pascal@13697
|
417 --title " Create a SliTaz Web boot floppy " \
|
pascal@13697
|
418 --yes-label "Create floppy" --yesno \
|
pascal@13697
|
419 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@13697
|
420 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@13697
|
421 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@13697
|
422 from the Web using PXE and HTTP protocols.\n\n
|
pascal@13697
|
423 Please insert a blank disk in floppy drive.\n
|
pascal@13697
|
424 " 12 70
|
pascal@13697
|
425 [ $? -eq 0 ] || return
|
pascal@15369
|
426 dd if=/media/cdrom/boot/?pxe of=/dev/fd0
|
pascal@13697
|
427 }
|
pascal@13697
|
428
|
pascal@16041
|
429 gotposixovl()
|
pascal@16041
|
430 {
|
pascal@16041
|
431 mount.posixovl 2>&1 | grep -qi usage &&
|
pascal@16041
|
432 echo -en "\"$1\" \"$2\""
|
pascal@16041
|
433 }
|
pascal@16041
|
434
|
pascal@14271
|
435 xfile()
|
pascal@14271
|
436 {
|
pascal@14271
|
437 [ -n "$(which $1)" ] && echo -en "\"$2\" \"$3\""
|
pascal@14271
|
438 }
|
pascal@14271
|
439
|
pascal@13697
|
440 cdfile()
|
pascal@13697
|
441 {
|
pascal@14271
|
442 [ -s /media/cdrom/$1 ] && echo -en "\"$2\" \"$3\""
|
pascal@14271
|
443 }
|
pascal@14271
|
444
|
pascal@16022
|
445 cdexe()
|
pascal@16022
|
446 {
|
pascal@16025
|
447 [ $(get 0 /media/cdrom/$1 2> /dev/null || echo 0) -eq 23117 ] &&
|
pascal@16022
|
448 echo -en "\"$2\" \"$3\""
|
pascal@16022
|
449 }
|
pascal@16022
|
450
|
pascal@14271
|
451 fddata()
|
pascal@14271
|
452 {
|
pascal@14271
|
453 [ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
|
pascal@14271
|
454 echo -en "\"$1\" \"$2\""
|
pascal@13697
|
455 }
|
pascal@13697
|
456
|
pascal@14257
|
457 fdbootstrap()
|
pascal@14257
|
458 {
|
pascal@14271
|
459 sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
|
pascal@14271
|
460 $DIALOG --clear \
|
pascal@14271
|
461 --title " Create a floppy bootstrap " \
|
pascal@14271
|
462 --yes-label "Continue" --yesno \
|
paul@14263
|
463 "\nThe floppy will install a driver to access the ISO file
|
pascal@14257
|
464 on your hard disk and will emulate a CD-ROM during the boot process.\n\n
|
pascal@14257
|
465 Please insert a floppy in drive now.\n
|
pascal@14257
|
466 " 10 70
|
pascal@14271
|
467 [ $? -eq 0 ] || return
|
pascal@14271
|
468 dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=512 \
|
pascal@14271
|
469 skip=$(( $(get 66 /mnt/$ISO) - $sz ))
|
pascal@14271
|
470 echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 count=1
|
pascal@14271
|
471 dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$sz seek=2 \
|
pascal@14271
|
472 skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 ))
|
pascal@14257
|
473 }
|
pascal@14257
|
474
|
pascal@14257
|
475 usbdev()
|
pascal@14257
|
476 {
|
pascal@14257
|
477 sleep 5
|
pascal@14257
|
478 DEV="$(grep -l 1 /sys/block/*/removable | \
|
pascal@14257
|
479 sed 's|/sys/block/\(.*\)/removable|\1|')"
|
pascal@14257
|
480 [ -n "$DEV" ] || return
|
pascal@14257
|
481 exec 3>&1
|
pascal@14257
|
482 device=`$DIALOG --clear \
|
pascal@14257
|
483 --title " Select your USB key " \
|
pascal@14257
|
484 --menu "\nPlease select the USB key according to its known size.\n\n" \
|
pascal@14257
|
485 14 70 4 \
|
pascal@14257
|
486 $(for i in $DEV ; do
|
pascal@14257
|
487 echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB"
|
pascal@14257
|
488 done) \
|
pascal@14257
|
489 2>&1 1>&3`
|
pascal@14257
|
490 retval=$?
|
pascal@14257
|
491 exec 3>&-
|
pascal@14257
|
492 [ $retval -eq 0 ]
|
pascal@14257
|
493 }
|
pascal@14257
|
494
|
pascal@14257
|
495 usbbootkey()
|
pascal@14257
|
496 {
|
pascal@14257
|
497 $DIALOG --clear \
|
pascal@14257
|
498 --title " Create a USB boot key " \
|
pascal@14257
|
499 --yes-label "Continue" --yesno \
|
pascal@14257
|
500 "\nThe USB key will be used like a CD-ROM. You will not be able to write
|
pascal@14257
|
501 any data on it.\n\n
|
pascal@14257
|
502 You should choose 'USB key read/write installation' to be
|
pascal@14257
|
503 able to save the package updates or your own configuration and data files.\n\n
|
pascal@14257
|
504 Please plug your USB stick in now.\n
|
pascal@14257
|
505 " 13 70
|
pascal@14257
|
506 [ $? -eq 0 ] || return
|
pascal@14257
|
507 usbdev || return
|
pascal@14257
|
508 dd if=/mnt/$ISO of=$device
|
pascal@14257
|
509 }
|
pascal@14257
|
510
|
pascal@13697
|
511 usbkey()
|
pascal@13697
|
512 {
|
pascal@13697
|
513 $DIALOG --clear \
|
pascal@13697
|
514 --title " Create a SliTaz USB key " \
|
pascal@13697
|
515 --yes-label "Continue" --yesno \
|
pascal@13697
|
516 "\nUnlike a hard drive install, the filesystem is kept in a compressed
|
pascal@13697
|
517 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
|
pascal@13697
|
518 This should increase responsiveness, protect the filesystem against
|
pascal@13697
|
519 accidental corruption and reduce read/writes to the USB drive.
|
pascal@13697
|
520 Once setup, the tazusb utility can rewrite the root filesystem
|
pascal@13697
|
521 with any changes you have made since booting up,
|
pascal@13697
|
522 giving the effective benefits of a hard drive install.\n\n
|
pascal@13697
|
523 /home is mounted on boot using the UUID of your particular flash drive.
|
pascal@13697
|
524 Unlike a device name, the UUID has the benefit of never changing from machine
|
pascal@13697
|
525 to machine.\n\n
|
pascal@13697
|
526 Please plug your USB stick in now.\n
|
pascal@14257
|
527 " 19 70
|
pascal@14271
|
528 [ $? -eq 0 ] || return
|
pascal@14257
|
529 usbdev || return
|
pascal@13697
|
530 exec 3>&1
|
pascal@13697
|
531 format=`$DIALOG --clear \
|
pascal@13697
|
532 --title " Select the filesystem " \
|
pascal@13733
|
533 --radiolist "\nPlease select the filesystem type to create.\n\n\
|
paul@13698
|
534 The filesystem creation will erase all the data \
|
pascal@13699
|
535 in the USB key." 14 70 4 \
|
pascal@13733
|
536 "none" "Do not erase the USB key" on \
|
pascal@13733
|
537 "ext3" "Ext3 journaling filesystem" off \
|
pascal@13733
|
538 "ext2" "Ext2 filesystem" off \
|
pascal@13733
|
539 "fat32" "Windows FAT32 filesystem" off \
|
pascal@13697
|
540 2>&1 1>&3`
|
pascal@13697
|
541 retval=$?
|
pascal@13697
|
542 exec 3>&-
|
pascal@14257
|
543 [ $retval -eq 0 ] || return
|
pascal@13697
|
544 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
|
pascal@13697
|
545 tazusb gen-iso2usb /mnt/$ISO $device
|
pascal@13697
|
546 }
|
pascal@13697
|
547
|
pascal@13713
|
548 mount_loram()
|
pascal@13713
|
549 {
|
pascal@13713
|
550 is_loram || return
|
pascal@13713
|
551 insmod /lib/squashfs.ko* 2> /dev/null
|
pascal@13713
|
552 if [ -d /media/cdrom/fs ]; then
|
pascal@13713
|
553 ln -s /media/cdrom/fs /sqfs
|
pascal@13713
|
554 else
|
pascal@13713
|
555 mkdir /sqfs
|
pascal@13713
|
556 mount -o loop,ro -t squashfs /rootfs*.gz /sqfs
|
pascal@13713
|
557 fi
|
pascal@13713
|
558 ln -s /sqfs/lib/* lib
|
pascal@13713
|
559 ln -s /sqfs/usr /sqfs/var /
|
pascal@13713
|
560 for i in dmesg basename tr od reboot poweroff getty sync ; do
|
pascal@13713
|
561 ln -s /sqfs/bin/busybox /bin/$i
|
pascal@13713
|
562 done
|
pascal@13713
|
563 }
|
pascal@13713
|
564
|
pascal@13713
|
565 umount_loram()
|
pascal@13713
|
566 {
|
pascal@13713
|
567 is_loram || return
|
pascal@13713
|
568 rm /var /usr
|
pascal@13713
|
569 umount -d /sqfs
|
pascal@13713
|
570 rmdir /sqfs
|
pascal@13713
|
571 }
|
pascal@13713
|
572
|
pascal@13691
|
573 text()
|
pascal@13691
|
574 {
|
pascal@13713
|
575 umount_loram
|
pascal@13691
|
576 umount -d /media/cdrom
|
pascal@16073
|
577 rm -f /dev/cdrom
|
pascal@13691
|
578 umount /mnt
|
pascal@16041
|
579 umount_proc
|
pascal@13691
|
580 exec /init
|
pascal@13691
|
581 }
|
pascal@13691
|
582
|
pascal@13691
|
583 live()
|
pascal@13691
|
584 {
|
pascal@13691
|
585 n=0
|
pascal@16041
|
586 for i in $(ls_r /media/cdrom/boot/rootfs* 2> /dev/null); do
|
pascal@13691
|
587 [ $((n++)) -eq 0 ] || uncpio $i
|
pascal@13691
|
588 done
|
pascal@13691
|
589 text
|
pascal@13691
|
590 }
|
pascal@13691
|
591
|
pascal@13713
|
592 restart()
|
pascal@13691
|
593 {
|
pascal@13713
|
594 sync
|
pascal@13713
|
595 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
|
pascal@13713
|
596 reboot -f
|
pascal@13691
|
597 }
|
pascal@13691
|
598
|
pascal@13713
|
599 stop()
|
pascal@13691
|
600 {
|
pascal@13713
|
601 sync
|
pascal@13713
|
602 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
|
pascal@13713
|
603 poweroff -f
|
pascal@13691
|
604 }
|
pascal@13691
|
605
|
pascal@13697
|
606 shell()
|
pascal@13697
|
607 {
|
pascal@13713
|
608 getty -n -l /bin/ash 38400 tty1 || sh
|
pascal@13697
|
609 }
|
pascal@13697
|
610
|
pascal@14247
|
611 BIN=bin/mount.posixovl
|
pascal@14247
|
612 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \
|
pascal@14247
|
613 /usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN
|
pascal@16041
|
614 mount_proc
|
pascal@13691
|
615 ISO="$(getarg iso | sed 's/.://;s|\\|/|g')"
|
pascal@13691
|
616 getiso
|
pascal@13713
|
617 mount_loram
|
pascal@16041
|
618 case "${ISO##*/}$(getarg mode)" in
|
pascal@16047
|
619 *install*|*INSTALL*) install ;;
|
pascal@16047
|
620 *live*|*LIVE*) live ;;
|
pascal@16047
|
621 *text*|*TEXT*) text ;;
|
pascal@13691
|
622 esac
|
pascal@16041
|
623 which $DIALOG 2> /dev/null || live
|
pascal@13713
|
624 dmesg > /tmp/dmesg
|
pascal@13691
|
625
|
pascal@13691
|
626 while true; do
|
pascal@16055
|
627 keymap="$(cat /etc/keymap.conf 2> /dev/null)"
|
pascal@16055
|
628 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)"
|
pascal@14271
|
629 cat > /tmp/dialog <<EOT
|
pascal@14271
|
630 $DIALOG --clear \
|
pascal@13691
|
631 --title " Welcome to SliTaz " \
|
pascal@14271
|
632 --menu "" 21 70 15 \
|
pascal@16055
|
633 $(xfile tazkeymap "tazkeymap" "Select keyboard ($keymap)") \
|
pascal@16055
|
634 $(xfile tazlocale "tazlocale" "Select locale ($locale)") \
|
pascal@16041
|
635 $(cdfile boot/bzImage "live" "SliTaz RAM boot") \
|
pascal@13697
|
636 "text" "SliTaz RAM boot (text mode only)" \
|
pascal@13697
|
637 $(cdfile README "readme" "Show the README file") \
|
pascal@13697
|
638 $(cdfile md5sum "md5" "Check ISO files") \
|
pascal@16041
|
639 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
|
pascal@16041
|
640 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
|
pascal@14271
|
641 $(xfile tazusb "usbkey" "USB key read/write installation") \
|
pascal@16041
|
642 $(cdfile boot/bzImage "usbbootkey" "USB boot key (read only)") \
|
pascal@14271
|
643 $(fddata "fdbootstrap" "Floppy bootstrap") \
|
pascal@16041
|
644 $(cdfile boot/bzImage "tazboot" "Get tazboot.exe Linux loader") \
|
pascal@16022
|
645 $(cdexe boot/memtest "memtest" "Get Memtest86") \
|
pascal@13697
|
646 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \
|
pascal@16022
|
647 $(cdexe boot/gpxe "pxe" "Get SliTaz Web boot utility") \
|
pascal@16012
|
648 $(cdfile boot/gpxe "fdpxe" "Create a SliTaz Web boot floppy") \
|
pascal@16022
|
649 $(cdexe boot/ipxe "pxe" "Get SliTaz Web boot utility") \
|
pascal@16012
|
650 $(cdfile boot/ipxe "fdpxe" "Create a SliTaz Web boot floppy") \
|
pascal@14271
|
651 $(xfile reboot "restart" "Restart the computer") \
|
pascal@14271
|
652 $(xfile poweroff "stop" "Power off") \
|
pascal@13697
|
653 "bootlog" "Linux boot messages" \
|
pascal@13697
|
654 "shell" "Shell prompt" \
|
pascal@14271
|
655
|
pascal@14271
|
656 EOT
|
pascal@14271
|
657 exec 3>&1
|
pascal@14271
|
658 value=$(sh /tmp/dialog 2>&1 1>&3)
|
pascal@13691
|
659 retval=$?
|
pascal@13691
|
660 exec 3>&-
|
pascal@13691
|
661 [ $retval -eq 0 ] || continue
|
pascal@13691
|
662 $value
|
pascal@13691
|
663 done
|