tazusb view tazusb-box @ rev 143
tazusb: update VERSION
author | Richard Dunbar <mojo@slitaz.org> |
---|---|
date | Tue Apr 23 01:22:11 2013 +0000 (2013-04-23) |
parents | a5f5b6aad358 |
children | 8ddffadf56a6 |
line source
1 #!/bin/sh
2 #
3 # Tiny GTK interface to SliTaz Live USB tool aka TazUSB.
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
6 #
7 # Authors : Christophe Lincoln <pankso@slitaz.org>
8 #
9 . /lib/libtaz.sh
11 # TazUSBbox is only for root.
12 if test $(id -u) != 0 ; then
13 exec tazbox su tazusb-box
14 exit 0
15 fi
17 # We can specify an ISO on cmdline: tazusb-box --iso=/path/to/image.iso
18 [ "$iso" ] || iso=" "
20 title="TazUSB Box"
21 icon="/usr/share/pixmaps/slitaz-icon.png"
22 opts="--window-icon=$icon --height=220 --width=520 --center --on-top"
24 # I18n
25 . /usr/bin/gettext.sh
26 TEXTDOMAIN='tazusb-box'
27 export TEXTDOMAIN
29 # Main text information
30 info="$(gettext "<b>Generate SliTaz LiveUSB media and boot in RAM!</b> \
31 Insert a LiveCD into the cdrom drive or use a local ISO image, select \
32 the correct device and press OK.")
33 "
35 #
36 # Functions
37 #
39 # Nice GTK output for commands.
40 output() {
41 yad --text-info $opts --title="$title" --tail --margins=4 \
42 --button="Reboot:reboot" --button="gtk-close:0"
43 }
45 list_devices() {
46 if [ -d /proc/scsi/usb-storage ]; then
47 dev="$(blkid | cut -d ":" -f 1)"
48 echo $dev | sed s'/ /!/'g
49 else
50 gettext "No USB media found"
51 fi
52 }
54 # Main GUI box function with pure Yad spec
55 usbbox_main() {
56 yad --form $opts --title="$title" --text="$info" \
57 --image=usb-creator --image-on-top \
58 --field="$(gettext "ISO Image:")":FL \
59 --field="$(gettext "USB Media:")":CB \
60 "$iso" "$(list_devices)"
61 }
63 # Handler
64 usbbox() {
65 # Store box results
66 main=$(usbbox_main)
68 # Deal with --button values
69 case $? in
70 1) exit 0 ;;
71 *) continue ;;
72 esac
74 # Deal with $main values. Exit if any device.
75 dev=$(echo $main | cut -d "|" -f 2)
76 if ! echo $dev | grep -q /dev; then
77 echo "No device: exit" && exit 0
78 fi
79 if echo "$main" | grep -q ".iso|"; then
80 iso=$(echo $main | cut -d "|" -f 1)
81 yes "" | tazusb gen-iso2usb $iso $dev --output=raw | output
82 else
83 yes "" | tazusb gen-liveusb $dev --output=raw | output
84 fi
85 }
87 #
88 # Script commands
89 #
91 case "$1" in
92 usage)
93 echo "Usage: $(basename $0) [list]" ;;
94 list)
95 list_devices ;;
96 *)
97 usbbox ;;
98 esac
100 exit 0