forked from thcp/pi_kube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash_and_setup.sh
executable file
·62 lines (50 loc) · 1.68 KB
/
flash_and_setup.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
#!/bin/bash
set -e
echo """
Before proceeding please update the following files:
- config.ini
- dhcpcd.conf
"""
read -p "Press any key to continue..."
source config.ini
#
# Download Raspbian Image
#
OUTFILE='raspbian_lite.zip'
if [ ! -f $OUTFILE ]; then
curl -L https://downloads.raspberrypi.org/raspbian_lite_latest -o "$OUTFILE"
fi
unzip "$OUTFILE"
#
# Download latest Etcher release
#
GITHUB_URL="https://api.github.com/repos/balena-io/etcher/releases/latest"
VERSION=$(curl -s $GITHUB_URL | grep -oP '"tag_name": "\K(.*)(?=")' | sed 's/v//g')
BASE_DOWNLOAD_URL="https://github.com/balena-io/etcher/releases/download"
if [[ "${OSTYPE}" == "darwin"* ]]; then
DOWNLOAD_URL="${BASE_DOWNLOAD_URL}/v${VERSION}/balenaEtcher-${VERSION}.dmg"
else
DOWNLOAD_URL="${BASE_DOWNLOAD_URL}/v${VERSION}/balena-etcher-electron-${VERSION}-linux-x64.zip"
fi
curl -L "${DOWNLOAD_URL}" -o etcher.zip && unzip etcher.zip && rm etcher.zip
echo """
###############################################
# Close Etcher after flashing...
###############################################
"""
./*"${VERSION}"*
echo "Create ssh file on /boot partition for enabling ssh server"
read -p "Press any key to continue..."
echo "Append content of cmdline.local.txt to /boot/cmdline.txt, please make a backup of the old one as cmdline.txt.bkp"
read -p "Press any key to continue..."
echo "Copy dhcpdcd.conf to /etc to your microsd root path"
read -p "Press any key to continue..."
echo
echo "Umount, boot your pi and perform the following commands: "
echo """
REMOTE_IP='ipaddr'
ssh-copy-id pi@\$REMOTE_IP
ssh pi@\$REMOTE_IP sudo passwd -l pi
scp config.ini setup.sh pi@\$REMOTE_IP:/home/pi
ssh pi@\$REMOTE_IP sh -c './setup.sh'
"""