-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflashLinux.sh
executable file
·51 lines (41 loc) · 1.38 KB
/
flashLinux.sh
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
#!/bin/bash
: '
Author: Lander Usategui email: [email protected]
'
if [ `whoami` != "root" ]; then
zenity --info --text "Execute this script with \"sudo\"\n\n \tsudo ./flashLinux.sh"
else
image=$(zenity --file-selection --title "Choose your OS")
if [ `echo $?` != "0" ]; then
zenity --error --title "Error" --text "Choose one OS"
else
device=$(zenity --file-selection --title "Choose your device")
if [ `echo $?` != "0" ]; then
zenity --error --title "Error" --text "Choose one device"
else
#Umount devices
flashDevice=`ls $device`
mountDevices=`ls $device*`
for i in `ls $device*`; do
sudo umount $mountDevices 2>/dev/null
done
#Check extension of the image
case $(echo `expr "$image" : '.*\.\(.*\)$'`) in
"gz")
(gunzip -c $image | dd of=$flashDevicebs=8M conv=sync,notrunc,noerror) | zenity --progress --pulsate --auto-close
zenity --info --title "Done!!" --text "Remove your SD."
;;
"img")
(dd if=$image of=$flashDevice bs=8M conv=sync,notrunc,noerror) | zenity --progress --pulsate --auto-close
zenity --info --title "Done!!" --text "Remove your SD."
;;
"xz")
(xz -dkc $image > $flashDevice) | zenity --progress --pulsate --auto-close
zenity --info --title "Done!!" --text "Remove your SD."
;;
*)
zenity --error --title "Error" --text "Not supported extension."
esac
fi
fi
fi