forked from davidfsmith/deepracer-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusb-build.sh
More file actions
executable file
·73 lines (57 loc) · 2.19 KB
/
usb-build.sh
File metadata and controls
executable file
·73 lines (57 loc) · 2.19 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
#!/usr/bin/env bash
usage()
{
echo "Usage: sudo $0 -d disk2 [ -s SSID -w WIFI_PASSWORD]"
exit 0
}
# Check we have the privileges we need
# if [ `whoami` != root ]; then
# echo "Please run this script as root or using sudo"
# exit 0
# fi
disk=disk2
ssid=NULL
wifiPass=NULL
optstring=":d:s:w:"
while getopts $optstring arg; do
case ${arg} in
d) disk=${OPTARG};;
s) ssid=${OPTARG};;
w) wifiPass=${OPTARG};;
?) usage ;;
esac
done
if [ $OPTIND -eq 1 ]; then
echo "No options selected."
usage
fi
diskutil partitionDisk /dev/${disk} MBR fat32 BOOT 4gb fat32 DEEPRACER 2gb exfat FLASH 14gb
# Grab the zip -> https://s3.amazonaws.com/deepracer-public/factory-restore/Ubuntu20.04/BIOS-0.0.8/factory_reset.zip
factoryResetURL=https://s3.amazonaws.com/deepracer-public/factory-restore/Ubuntu20.04/BIOS-0.0.8/factory_reset.zip
if [ ! -d factory_reset ]; then
curl -O ${factoryResetURL}
unzip factory_reset.zip
# uncomment `# reboot` on lines 520 & 528 of `usb_flash.sh`
cp factory_reset/usb_flash.sh factory_reset/usb_flash.sh.bak
rm factory_reset/usb_flash.sh
cat factory_reset/usb_flash.sh.bak | sed -e "s/#reboot/reboot/g" > factory_reset/usb_flash.sh
fi
rsync -av --progress factory_reset/* /Volumes/FLASH
# Grab the ISO -> https://s3.amazonaws.com/deepracer-public/factory-restore/Ubuntu20.04/BIOS-0.0.8/ubuntu-20.04.1-20.11.13_V1-desktop-amd64.iso
isoFilename=ubuntu-20.04.1-20.11.13_V1-desktop-amd64.iso
isoURL=https://s3.amazonaws.com/deepracer-public/factory-restore/Ubuntu20.04/BIOS-0.0.8/ubuntu-20.04.1-20.11.13_V1-desktop-amd64.iso
if [ ! -f ${isoFilename} ]; then
curl -O ${isoURL}
fi
# Issues with OSX Ventura -> https://github.com/unetbootin/unetbootin/issues/337
# https://github.com/unetbootin/unetbootin/wiki/commands
sudo /Applications/unetbootin.app/Contents/MacOS/unetbootin method=diskimage isofile=ubuntu-20.04.1-20.11.13_V1-desktop-amd64.iso installtype=USB targetdrive=/dev/${disk}s1 autoinstall=yes
# Create wifi-creds.txt for auto network goodness
if [ ${ssid} != NULL ] && [ ${wifiPass} != NULL ]; then
cat > /Volumes/DEEPRACER/wifi-creds.txt << EOF
ssid: ${ssid}
password: ${wifiPass}
EOF
fi
echo "Done"
exit 0