-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_amity
executable file
·60 lines (48 loc) · 1.73 KB
/
setup_amity
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
#!/bin/bash
set -xe
NAME=amity
ROOT_DIR=~
APP_DIR=$ROOT_DIR/$NAME
FIRMWARE_PATH=/boot/firmware
strstr() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
# Initial sanity check that the hardware is supported, and prep info in case the kernel
# needs to be updated to support cec-gpio
RPI_MODEL=`cat /sys/firmware/devicetree/base/model`
if strstr "Raspberry Pi 4" "$RPI_MODEL" ||
strstr "Raspberry Pi 3 Model B" "$RPI_MODEL" ||
strstr "Raspberry Pi Zero 2 W" "$RPI_MODEL"; then
KERNEL_ARCHIVE_URL="https://github.com/retsyx/amity-kernels/blob/main/kernel-6.6.51/kernel-6.6.51-v8-amity.zip?raw=true"
KERNEL_IMG=kernel8.img
elif strstr "Raspberry Pi 5" "$RPI_MODEL"; then
KERNEL_ARCHIVE_URL="https://github.com/retsyx/amity-kernels/blob/main/kernel-6.6.51/kernel-6.6.51-v8-16k-amity.zip?raw=true"
KERNEL_IMG=kernel_2712.img
else
echo "${RPI_MODEL} is not a known model (if it is older than a Raspberry Pi 3 Model B, it is not supported)"
exit 1
fi
# Kernel setup
KERNEL_HAS_CEC_GPIO=`gunzip -c "$FIRMWARE_PATH/$KERNEL_IMG" | grep -c cec-gpio || true`
cd "$ROOT_DIR"
if [ ! -d "$APP_DIR" ]; then
sudo apt-get -y update
sudo apt-get -y install git
git clone https://github.com/retsyx/amity.git
# Setup a venv
python -m venv "$APP_DIR"
else
pushd $APP_DIR
git fetch && git rebase
popd
fi
# If necessary, download, and install cec-gpio enabled kernel, and reboot
if [ "$KERNEL_HAS_CEC_GPIO" -eq "0" ]; then
KERNEL_ARCHIVE_DIR="$ROOT_DIR/linux-build/out"
mkdir -p $KERNEL_ARCHIVE_DIR
curl -L --remote-name --output-dir "$KERNEL_ARCHIVE_DIR" "$KERNEL_ARCHIVE_URL"
fi
cd $APP_DIR
./build/setup-amity-core.sh
if [ "$KERNEL_HAS_CEC_GPIO" -eq "0" ]; then
sleep 5
sudo shutdown -r now
fi