wok annotate syslinux/stuff/iso2exe/init @ rev 17569

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