-
Notifications
You must be signed in to change notification settings - Fork 12
/
install_opi5.sh
executable file
·82 lines (63 loc) · 2.56 KB
/
install_opi5.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
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash -v
# Create pi/raspberry login
if id "$1" >/dev/null 2>&1; then
echo 'user found'
else
echo "creating pi user"
useradd pi -m -b /home -s /bin/bash
usermod -a -G sudo pi
echo 'pi ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers.d/010_pi-nopasswd >/dev/null
chmod 0440 /etc/sudoers.d/010_pi-nopasswd
fi
echo "pi:raspberry" | chpasswd
apt-get update --quiet
before=$(df --output=used / | tail -n1)
# clean up stuff
# get rid of snaps
echo "Purging snaps"
rm -rf /var/lib/snapd/seed/snaps/*
rm -f /var/lib/snapd/seed/seed.yaml
apt-get purge --yes --quiet lxd-installer lxd-agent-loader
apt-get purge --yes --quiet snapd
# remove bluetooth daemon
apt-get purge --yes --quiet bluez
apt-get --yes --quiet autoremove
after=$(df --output=used / | tail -n1)
freed=$(( before - after ))
echo "Freed up $freed KiB"
# run Photonvision install script
chmod +x ./install.sh
./install.sh --install-nm=yes --arch=aarch64
echo "Installing additional things"
apt-get install --yes --quiet libc6 libstdc++6
# let netplan create the config during cloud-init
rm -f /etc/netplan/00-default-nm-renderer.yaml
# set NetworkManager as the renderer in cloud-init
cp -f ./OPi5_CIDATA/network-config /boot/network-config
# add customized user-data file for cloud-init
cp -f ./OPi5_CIDATA/user-data /boot/user-data
# modify photonvision.service to enable big cores
sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=4-7/g' /lib/systemd/system/photonvision.service
cp -f /lib/systemd/system/photonvision.service /etc/systemd/system/photonvision.service
chmod 644 /etc/systemd/system/photonvision.service
cat /etc/systemd/system/photonvision.service
# networkd isn't being used, this causes an unnecessary delay
systemctl disable systemd-networkd-wait-online.service
# PhotonVision server is managing the network, so it doesn't need to wait for online
systemctl disable NetworkManager-wait-online.service
# the bluetooth service isn't needed and causes problems with cloud-init
# the chip has different names on different boards. Examples are:
# OrangePi5: ap6275p-bluetooth.service
# OrangePi5pro: ap6256s-bluetooth.service
# OrangePi5b: ap6275p-bluetooth.service
# OrangePi5max: ap6611s-bluetooth.service
# instead of keeping a catalog of these services, find them based on a pattern and mask them
btservices=$(systemctl list-unit-files *bluetooth.service | tail -n +2 | head -n -1 | awk '{print $1}')
for btservice in $btservices; do
echo "Masking: $btservice"
systemctl mask "$btservice"
done
rm -rf /var/lib/apt/lists/*
apt-get --yes --quiet clean
rm -rf /usr/share/doc
rm -rf /usr/share/locale/