-
Notifications
You must be signed in to change notification settings - Fork 1
/
RaspiBRSetup.sh
executable file
·51 lines (41 loc) · 1.27 KB
/
RaspiBRSetup.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
#!/bin/bash
# A script to setup a fresh Raspberry Pi as Thread Border Router
# Function to die with error
die() { echo "Error: " "$*" 1>&2 ; exit 1; }
INSTALL_BRANCH="master"
# Get options passed to script, such as branch ids
# First ':' is so that missing argument is reported
# 'b:' accept -b option with required argument
while getopts ":b:r:" opt; do
case ${opt} in
b )
INSTALL_BRANCH=${OPTARG}
;;
: )
echo "Invalid option, -${OPTARG} requires argument" 1>&2
;;
esac
done
# System upgrade
sudo apt update -y || die "sudo apt update"
sudo apt upgrade -y || die "sudo apt upgrade"
# Clone the install-script repo and run the BR setup script
MYDIR=$(dirname "$0")
BR_SCRIPT="${MYDIR}/_BRSetup.sh"
if [ ! -f "${BR_SCRIPT}" ]
then
echo "Target script branch is ${INSTALL_BRANCH}"
sudo apt install git -y || die "Installing git"
if [ -d install-script/.git ]
then
git -C install-script pull || git -C install-script fetch || die "Fetching install-script"
else
git clone https://github.com/Cascoda/install-script.git || die "Cloning install-script"
fi
git -C install-script checkout "${INSTALL_BRANCH}" || die "Checking out install-script tag"
cd install-script || die "cd"
./_BRSetup.sh "$@"
else
# run install script
${BR_SCRIPT} "$@" || die "Running script"
fi