forked from sensorgnome-org/sensorgnome-build
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflash-cm.sh
More file actions
executable file
·28 lines (25 loc) · 790 Bytes
/
flash-cm.sh
File metadata and controls
executable file
·28 lines (25 loc) · 790 Bytes
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
#! /bin/bash -e
if [[ -z $1 ]]; then echo "usage: $0 <url>"; exit 1; fi
url=$1
zip=$(basename $1)
img=$(basename $1 zip)img
cd /tmp
if ! [[ -f $zip ]]; then
echo Downloading $url
wget -nv -O $zip $url
fi
echo Unmounting
umount /run/media/$USER/* 2>/dev/null || true
dev=$(lsblk -d -o NAME,VENDOR,SIZE | grep -E 'RPi-MSD.*[2356][0-9]\.[0-9]G' | cut -d" " -f1)
if [[ -z $dev ]]; then
echo "No device found, running rpiusbboot"
sudo rpiusbboot
sleep 5
dev=$(lsblk -d -o NAME,VENDOR,SIZE | grep -E 'RPi-MSD.*[2356][0-9]\.[0-9]G' | cut -d" " -f1)
if [[ -z $dev ]]; then echo "No device found."; exit 1; fi
fi
dev=/dev/$dev
echo "Flashing $dev: $(lsblk -dn -o VENDOR,MODEL,SIZE $dev)"
echo "Takes 15-20 minutes!"
sleep 5
7z e -so $zip $img | sudo dd of=$dev bs=10M