forked from cyberorg/live-fat-stick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive-usb-gui
More file actions
executable file
·136 lines (126 loc) · 4.06 KB
/
live-usb-gui
File metadata and controls
executable file
·136 lines (126 loc) · 4.06 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# live-usb-gui : Simple GUI to create bootable usb stick from iso images
# Copyright (c) 2012 CyberOrg Info
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Authors: Jigish Gohil <cyberorg@opensuse.org>
# This script creates bootable openSUSE, Fedora or Ubuntu(or clones) live usb stick on fat partition
#
if [[ $(id -u) != 0 ]]; then
echo "run this command as root"
exit 1
fi
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin
if [ x"$WINDOWMANAGER" = x"/usr/bin/startkde" ]; then
which kdialog &>/dev/null && popup=kdialog
else
which zenity &>/dev/null && popup=zenity
fi
popup=${popup:-zenity}
which $popup &>/dev/null || echo "$popup not found, please install to use this tool"
which live-fat-stick &>/dev/null || echo "live-fat-stick script not found in PATH, please install it and make it executable"
export livestickgui=$(mktemp)
clean_up () {
rm $livestickgui
}
fileselecttitle="Select distribution iso file"
fileselectpath="/"
fileselectfilter="*iso"
usbselecttitle="Select the target USB device"
distributionlist="suse fedora mint ubuntu"
distrotitle="Select the distribution of the iso"
usbdevicelist=$(for i in `echo $(for i in $(find /dev/disk/by-id/ |grep usb); do readlink -f $i;done)`
do
if [[ $(blkid -s TYPE -o value $i) == vfat ]];then
echo $i
fi
done)
usbdevicelistkd=$(for device in $usbdevicelist; do
printf "%s %s %s" ${device} ${device} off
printf "\n"
done)
distributionlistkd=$(for distro in $distributionlist; do
printf "%s %s %s" $distro $distro off
printf "\n"
done)
check_variable () {
if [ ! "$1" ]; then
clean_up
exit 1
fi
}
if [[ $popup == zenity ]]; then
sourceiso=$(zenity --file-selection --title="$fileselecttitle" --file-filter="$fileselectfilter")
check_variable $sourceiso
usbdevice=$(zenity --list --title="$usbselecttitle" --column="USB device" $usbdevicelist)
check_variable $usbdevice
distroname=$(zenity --list --title="distrotitle" --column="Distribution:" $distributionlist)
check_variable $distroname
else
sourceiso=$(kdialog --title "$fileselecttitle" --getopenfilename "$fileselectpath" "$fileselectfilter")
check_variable $sourceiso
usbdevice=$(kdialog --separate-output --title "$usbselecttitle" --checklist "USB device:" $usbdevicelistkd)
check_variable $usbdevice
distroname=$(kdialog --separate-output --title "$distrotitle" --checklist "Distribution:" $distributionlistkd)
check_variable $distroname
fi
case $distroname in
fedora)
option="--fedora"
;;
suse)
option="--suse"
;;
ubuntu)
option="--ubuntu"
;;
mint)
option="--ubuntu"
;;
esac
if [ ! "$option" ]; then
clean_up
exit 1
fi
questiontitle="Is the information below correct?"
questiontext="Distribution: $distroname \nISO image: $sourceiso \nUSB device: $usbdevice"
errortext="oops, something went wrong"
successtext="Your bootable usb device is now ready"
if [[ $popup == zenity ]]; then
if ! zenity --question --title="$questiontitle" --text "$questiontext"; then
clean_up
exit 1
fi
else
if ! kdialog --title "$questiontitle" --warningcontinuecancel "$questiontext"; then
clean_up
exit 1
fi
fi
live-fat-stick $option $sourceiso $usbdevice
if [ $? != 0 ]; then
if [[ $popup == zenity ]]; then
zenity --error --text="$errortext"
else
kdialog --error "$errortext"
fi
else
if [[ $popup == zenity ]]; then
zenity --info --text="$successtext"
else
kdialog --msgbox "$successtext"
fi
fi
clean_up