#!/bin/bash # # toorox-iso2usb # # Make a bootable Toorox Live USB-Drive without the DVD # # The following packages must be installed: # xdialog or dialog, gawk, syslinux, parted # # GPL - 2 # # Author: Joern Lindau # XDIALOG=`find /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -name Xdialog` GAWK=`find /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -name awk` SYSLINUX=`find /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -name extlinux` PARTED=`find /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -name parted` if [ -z "$XDIALOG" ] then DIALOG="dialog" else DIALOG="Xdialog" fi VAR=`$DIALOG --title "$TITEL" --radiolist "Auswahl Sprache/Choose Language" 15 60 3\ Deutsch "" off \ English "" off 3>&1 1>&2 2>&3` if [ "$VAR" = "Deutsch" ] then LANGUAGE="de" else LANGUAGE="us" fi if [ "$LANGUAGE" = "de" ] then MSG1="Sie müssen das Skript als root ausführen!" MSG3="\"gawk\" nicht gefunden! Bitte installieren Sie das Paket und starten erneut dieses Skript." MSG4="\"syslinux\" nicht gefunden! Bitte installieren Sie das Paket und starten erneut dieses Skript." MSG5="\"parted\" nicht gefunden! Bitte installieren Sie das Paket und starten erneut dieses Skript." TL="Fehler" else MSG1="You must be root!" MSG3="\"gawk\" not found! Please install this package and start this script again." MSG4="\"syslinux\" not found! Please install this package and start this script again." MSG5="\"parted\" not found! Please install this package and start this script again." TL="Error" fi [ -z "$GAWK" ] && $DIALOG --title "$TL" --msgbox "$MSG3" 10 60 && exit 0 [ -z "$SYSLINUX" ] && $DIALOG --title "$TL" --msgbox "$MSG4" 10 60 && exit 0 [ -z "$PARTED" ] && $DIALOG --title "$TL" --msgbox "$MSG5" 10 60 && exit 0 TITLE="Toorox Iso2Stick" if [ `id -u` -ne 0 ] then $DIALOG --title "$TL" --msgbox "$MSG1" 0 0 exit 1 fi if [ "$LANGUAGE" = "de" ] then MSG1="Mit diesem Skript können Sie einen Toorox Live USB-Stick erstellen. Der Autor und toorox.de können nicht verantwortlich gemacht werden für Datenverlust und Schäden an der Hardware. Autor: Jörn Lindau Akzeptieren Sie diese Bedingungen und möchten fortfahren?" MSG2="Bitte entfernen Sie alle USB-Sticks. Weiter mit OK ..." MSG3="Stecken Sie nun den Stick(min 4 GB) ein und klicken OK. Die Initialisierung dauert ein paar Sekunden ..." MSG4="Bitte Stick auswählen:" MSG8="Grösse des Sticks:" MSG9="Kopiervorgang beendet. Sie haben nun einen Toorox Live-Stick. Um den Stick zu booten, müssen Sie beim nächsten Neustart das 1.Bootgerät im BIOS bzw. die 1. Boot Festplatte auf USB-HDD ändern oder beim Neustart direkt in das Bootmenü des Mainboards gehen (Hinweis dafür erscheint auf dem Bildschirm, sobald Sie den PC einschalten - z.B. Taste F11 oder ESC drücken)." MSG16="Toorox .iso Datei auswählen" else MSG1="This script makes a Toorox Live USB-Stick. The author and toorox.de cannot be made responsible for lost data and damage to the hardware. Author: Jörn Lindau Do you agree to this terms?" MSG2="Please remove all pendrives. Next click OK ..." MSG3="Now plugin your pendrive(min 4GB) and click OK. The initialization takes a few seconds ..." MSG4="Choose the target stick:" MSG8="Size of the stick:" MSG9="Copy process finished. Now you have a Toorox Live-Stick. For booting you have to go into the BIOS-Setup and change the first boot device or the first boot hard disk device to USB-HDD. Another way is to open the boot menu directly when you turn on the PC. The magic key for the boot menu should be displayed first on the screen when you turn on the PC (e.g. F11 or ESC)." MSG16="Select the Toorox .iso file" fi copy() { if [ "$LANGUAGE" = "de" ] then MSG5="Das iso Image wird nun auf die Zielpartition $TARGET 2 des Sticks geschrieben. Dieser Vorgang wird einige Minuten dauern. Nein = Abbruch" else MSG5="The image file will now be written on the target partition $TARGET 2 of the stick. This process will take a few minutes. No - Exit" fi ISO=`$DIALOG --title "$MSG16" --fselect "/" 40 100 3>&1 1>&2 2>&3` [ -z "$ISO" ] && exit 0 $DIALOG --title "$TITLE" --yesno "$MSG5" 10 60 [ $? -eq 1 ] && exit 0 [ ! -d /tmp/toorox-stick ] && mkdir -p /tmp/toorox-stick [ ! -d /tmp/toorox-iso ] && mkdir -p /tmp/toorox-iso mount $ISO /tmp/toorox-iso mount "$TARGET"2 /tmp/toorox-stick cd /tmp/toorox-stick cp /tmp/toorox-iso/boot/* ./ cp /tmp/toorox-iso/boot/isolinux/* ./ cp -a /tmp/toorox-iso/* ./ mv isolinux.cfg extlinux.conf rm isolinux.bin rm -r boot/ extlinux -i /tmp/toorox-stick cd /tmp/toorox-stick tar -xjf syslinux-4.03.tar.bz2 cp syslinux-4.03/mbr/mbr.bin /tmp sync umount /tmp/toorox-stick umount /tmp/toorox-iso cat /tmp/mbr.bin > $TARGET } $DIALOG --title "$TITLE" --yesno "$MSG1" 0 0 answer=$? if [ $answer -ne 0 ] then exit 0 fi $DIALOG --title "$TITLE" --msgbox "$MSG2" 10 60 dmesg -c 1> /dev/null $DIALOG --title "$TITLE" --msgbox "$MSG3" 10 60 sleep 10 USB=`dmesg | grep removable | cut -d '[' -f 3 | cut -d ']' -f 1` if [ -z "$USB" ]; then USB=`dmesg | grep removable | cut -d ' ' -f 3 | cut -c 2,3,4` fi DEVICE=`for var in $USB; do echo "/dev/$var"; done` set $DEVICE TARGET=`$DIALOG --title "$TITLE" --radiolist "$MSG4" 15 60 3 \ :$1 "" off \ :$2 "" off \ :$3 "" off 3>&1 1>&2 2>&3 | cut -c2-11` [ -z "$TARGET" ] && exit 0 if [ "$LANGUAGE" = "de" ] then MSG6="WARNUNG!!! Das USB-Gerät $TARGET wird komplett gelöscht und bootfähig gemacht. Alle Daten auf dem Gerät gehen verloren! Danach werden 2 Partitionen auf dem Stick erstellt - eine für Toorox und der Rest wird mit FAT32 formatiert, damit der Stick auch weiterhin für normale Datensicherung benutzt werden kann. Der Vorgang wird einige Minuten dauern. Falls Sie die .iso Datei auf einer anderen Partition gespeichert haben, müssen Sie diese, sobald die Dateiauswahl erscheint, erneut mit dem Dateimanager einbinden und dann unter /media/... auswählen. Möchten Sie fortfahren?" else MSG6="Warning!!! The USB device $TARGET will be completely erased and prepared. All data on the device will be lost! Then 2 new partitions will be created on the stick - one for Toorox and the rest will be a FAT32 partition for normal data storages. The process will take a few minutes. If you've stored the .iso file on another partition you have to mount it again with the filemanager when you see the file choosing dialog next step and choose the .iso file under /media/... Would you like to go on?" fi SIZE=`$DIALOG --title "$TITLE" --radiolist "$MSG8" 15 60 5 \ 4GB "" on \ 8GB "" off \ 16GB "" off \ 32GB "" off \ 64GB "" off 3>&1 1>&2 2>&3` [ -z "$SIZE" ] && exit 0 case "$SIZE" in 4GB) umount -f /media/* 2>/dev/null umount -f /mnt/* 2>/dev/null $DIALOG --title "$TITLE" --yesno "$MSG6" 25 65 if [ $? -eq 0 ]; then parted $TARGET mktable msdos -s 1>/dev/null parted $TARGET mkpart primary fat32 0 1000 -s 1>/dev/null parted $TARGET mkpart primary ext2 1001 4000 -s 1>/dev/null parted $TARGET toggle 2 Boot 1>/dev/null mkdosfs -F 32 $TARGET\1 1>/dev/null mke2fs $TARGET\2 1>/dev/null copy else exit 0 fi ;; 8GB) umount -f /media/* 2>/dev/null umount -f /mnt/* 2>/dev/null $DIALOG --title "$TITLE" --yesno "$MSG6" 25 65 if [ $? -eq 0 ]; then parted $TARGET mktable msdos -s 1>/dev/null parted $TARGET mkpart primary fat32 0 5000 -s 1>/dev/null parted $TARGET mkpart primary ext2 5001 8000 -s 1>/dev/null parted $TARGET toggle 2 Boot 1>/dev/null mkdosfs -F 32 $TARGET\1 1>/dev/null mke2fs $TARGET\2 1>/dev/null copy else exit 0 fi ;; 16GB) umount -f /media/* 2>/dev/null umount -f /mnt/* 2>/dev/null $DIALOG --title "$TITLE" --yesno "$MSG6" 25 65 if [ $? -eq 0 ]; then parted $TARGET mktable msdos -s 1>/dev/null parted $TARGET mkpart primary fat32 0 13000 -s 1>/dev/null parted $TARGET mkpart primary ext2 13001 16000 -s 1>/dev/null parted $TARGET toggle 2 Boot 1>/dev/null mkdosfs -F 32 $TARGET\1 1>/dev/null mke2fs $TARGET\2 1>/dev/null copy else exit 0 fi ;; 32GB) umount -f /media/* 2>/dev/null umount -f /mnt/* 2>/dev/null $DIALOG --title "$TITLE" --yesno "$MSG6" 25 65 if [ $? -eq 0 ]; then parted $TARGET mktable msdos -s 1>/dev/null parted $TARGET mkpart primary fat32 0 29000 -s 1>/dev/null parted $TARGET mkpart primary ext2 29001 32000 -s 1>/dev/null parted $TARGET toggle 2 Boot 1>/dev/null mkdosfs -F 32 $TARGET\1 1>/dev/null mke2fs $TARGET\2 1>/dev/null copy else exit 0 fi ;; 64GB) umount -f /media/* 2>/dev/null umount -f /mnt/* 2>/dev/null $DIALOG --title "$TITLE" --yesno "$MSG6" 25 65 if [ $? -eq 0 ]; then parted $TARGET mktable msdos -s 1>/dev/null parted $TARGET mkpart primary fat32 0 61000 -s 1>/dev/null parted $TARGET mkpart primary ext2 61001 64000 -s 1>/dev/null parted $TARGET toggle 2 Boot 1>/dev/null mkdosfs -F 32 $TARGET\1 1>/dev/null mke2fs $TARGET\2 1>/dev/null copy else exit 0 fi ;; *) exit 0 ;; esac $DIALOG --title "$TITLE" --msgbox "$MSG9" 17 60 exit 0