-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtazusb-box
executable file
·117 lines (84 loc) · 1.99 KB
/
tazusb-box
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
#
# Tiny GTK interface to SliTaz Live USB tool aka TazUSB.
#
# Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
#
# Authors : Christophe Lincoln <pankso@slitaz.org>
#
. /lib/libtaz.sh
# TazUSBbox is only for root.
if [ $(id -u) -ne 0 ]; then
exec tazbox su tazusb-box
exit 0
fi
# We can specify an ISO on cmdline: tazusb-box --iso=/path/to/image.iso
[ "$iso" ] || iso=" "
title='TazUSB Box'
icon='/usr/share/pixmaps/slitaz-icon.png'
opts="--window-icon=$icon --height=220 --width=520 --center --on-top"
# i18n
export TEXTDOMAIN='tazusb-box'
# Main text information
info="<b>$(_ 'Generate SliTaz LiveUSB media and boot in RAM!')</b>\n\n \
$(_ "Insert a LiveCD into the CD-ROM drive or use a local ISO image, select \
the correct device and press OK.")
"
#
# Functions
#
# Nice GTK output for commands.
output() {
yad --text-info $opts --title="$title" --tail --margins=4 \
--button="$(_n 'Reboot'):reboot" --button="gtk-close:0"
}
list_devices() {
if [ -d /proc/scsi/usb-storage ]; then
dev="$(blkid | cut -d: -f1)"
echo $dev | sed s'/ /!/'g
else
_ 'No USB media found'
fi
}
# Main GUI box function with pure Yad spec
usbbox_main() {
yad --form $opts --title="$title" --text="$info" \
--image=usb-creator --image-on-top \
--field="$(_n 'ISO Image:')":FL \
--field="$(_n 'USB Media:')":CB \
"$iso" "$(list_devices)"
}
# Handler
usbbox() {
# Store box results
main=$(usbbox_main)
# Deal with --button values
case $? in
1) exit 0 ;;
*) continue ;;
esac
# Deal with $main values. Exit if any device.
dev=$(echo $main | cut -d"|" -f2)
if ! echo $dev | grep -q /dev; then
_ 'No device: exit'
exit 0
fi
if echo "$main" | grep -q ".iso|"; then
iso=$(echo $main | cut -d "|" -f1)
yes '' | tazusb gen-iso2usb $iso $dev --output=raw | output
else
yes '' | tazusb gen-liveusb $dev --output=raw | output
fi
}
#
# Script commands
#
case "$1" in
usage|--help|-h)
echo "$(_ 'Usage:') $(basename $0) [list]" ;;
list)
list_devices ;;
*)
usbbox ;;
esac
exit 0