/
ebin-sd-pi.sh
71 lines (64 loc) · 2.31 KB
/
ebin-sd-pi.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# ==============================================================================
# ==============================================================================
#
# EspressoBin Config
# Kodi/OSMC Media Server
# September, 2019
# https://github.com/ChameleonGeek/ebin-kodi
#
# This script uses a Raspberry Pi SBC to download the EspressoBin
# Ubuntu 16.04 LTS server image, prepare a MicroSD card for the EspressoBin
# and export the image files to the MicroSD card.
#
# This script is the first step of configuring the EspressoBin. It expects
# a Raspberry Pi running Raspbian connected to the internet. The MicroSD card
# must have a single partition and must be formatted with a filesystem the RasPi
# can read and write. The MicroSD card needs to be connected to the RasPi with
# a USB MicroSD reader.
#
# ==============================================================================
# ==============================================================================
cd ~
DLSTATUS=0
EXTRACTED=0
# Determine if the image needs to be downloaded/extracted
if [ -e 'rootfs.tar.bz2' ]; then
EXTRACTED=1
fi
if [ -e 'ebin-ubuntu-16.04.3.zip' ]; then
DLSTATUS=1
fi
if [ $DLSTATUS = 0 ] && [ $EXTRACTED = 0 ]; then
# IMAGE HAS NOT BEEN DOWNLOADED OR EXTRACTED
wget http://espressobin.net/wp-content/uploads/2017/10/ebin-ubuntu-16.04.3.zip
fi
if [ $EXTRACTED = 0 ]; then
# IMAGE HAS BEEN DOWNLOADED BUT NOT EXTRACTED
unzip ebin-ubuntu-16.04.3.zip
fi
if ! [ -e 'rootfs.tar.bz2' ]; then
echo "The EspressoBin file system has not been extracted."
exit
fi
# OS IMAGE HAS BEEN DOWNLOADED AND UNZIPPED. NOW PREPARE THE SD CARD
DEVICEPATH=$(whiptail --title "Device Path" --inputbox "Enter the device path for the SD card" 8 78 "/dev/sda1" 3>&1 1>&2 2>&3)
esa=$?
if [ "$esa" = "0" ]; then
sudo umount "${DEVICEPATH}"
sudo mkdir /ebincard
sudo mkfs -t ext4 "${DEVICEPATH}"
sudo mount "${DEVICEPATH}" /ebincard
cd /ebincard
sudo tar -xvf ~/rootfs.tar.bz2
#cd /home/pi
cd ~
sudo umount /ebincard
sudo rm -rf /ebincard
echo "Card has been prepped and is safe to disconnect."
else
echo "Card prep failed."
if ! [ -e 'ebin-ubuntu-16.04.3.zip' ]; then
echo "The image zip file has not been downloaded."
fi
fi