-
Notifications
You must be signed in to change notification settings - Fork 2
/
flashear.sh
executable file
·48 lines (36 loc) · 953 Bytes
/
flashear.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
#!/bin/bash
: '
maintainer Lander Usategui, e-mail: [email protected]
'
clear
# CONSTANTS
IMAGE_PATH="/Users/lander/ImagesFlash" #Change for your path
DEVICE="/dev/disk2" #Change for your device
FLASH_DEVICE="/dev/rdisk2" #Change for your device
IMAGES_FLASH=$(ls "$IMAGE_PATH")
cont=1
indexArray=0
imageArray=( )
for i in $IMAGES_FLASH; do
echo "$cont- $i"
imageArray[$indexArray]=$i
indexArray=$(($indexArray+1))
cont=$(($cont+1))
done
read -p "Choose the image: " flash
if [ $flash -gt ${#imageArray[@]} ] || [ $flash -lt 0 ]; then
clear
echo "Invalid number, launch the script again and choose one number of the list"
else
clear
flash=$(($flash-1))
if [ "`diskutil unmountDisk $DEVICE 2>/dev/null`" ]; then
echo "Unmounted correctly"
echo "Flashing, please wait..."
gunzip -c $IMAGE_PATH/${imageArray[$flash]} | sudo dd of=$FLASH_DEVICE bs=8m
else
clear
echo "Please, change the device number"
fi
fi
exit 0