Skip to content

Commit

Permalink
update the networking configuration for OPi's
Browse files Browse the repository at this point in the history
  • Loading branch information
crschardt committed Jul 21, 2024
1 parent 53a09d3 commit db8325c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 48 deletions.
42 changes: 13 additions & 29 deletions OPi5_CIDATA/network-config
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,21 @@ network:
version: 2
renderer: NetworkManager
ethernets:
end1:
dhcp4: true
dhcp6: false
addresses:
- 192.0.2.2/24
zz-all-en:
renderer: NetworkManager
match:
name: "en*"
dhcp4: true
optional: true
zz-all-eth:
match:
name: "eth*"
dhcp4: true
optional: true

# wifis:
# wlan0:
# dhcp4: true
# optional: true
# access-points:
# myhomewifi:
# password: "S3kr1t"
# myworkwifi:
# password: "correct battery horse staple"
# workssid:
# auth:
# key-management: eap
# method: peap
# identity: "[email protected]"
# password: "passw0rd"
# ca-certificate: /etc/my_ca.pem
link-local:
- ipv4
networkmanager:
passthrough:
ipv4.dhcp-timeout: "2147483647"
ipv4.link-local: "3"
ipv6.method: "disabled"
# zz-all-eth:
# match:
# name: "eth*"
# dhcp4: true
# optional: true

# regulatory-domain: GB
9 changes: 6 additions & 3 deletions OPi5_CIDATA/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ users:
# On first boot, set the (default) ubuntu user's password to "ubuntu" and
# expire user passwords
chpasswd:
expire: true
expire: false
users:
- name: ubuntu
password: ubuntu
password: photon
type: text

## Set the system's hostname. Please note that, unless you have a local DNS
## setup where the hostname is derived from DHCP requests (as with dnsmasq),
## setting the hostname here will not make the machine reachable by this name.
## You may also wish to install avahi-daemon (see the "packages:" key below)
## to make your machine reachable by the .local domain
#hostname: ubuntu
hostname: photonvision

## Set up the keyboard layout. See localectl(1), in particular the various
## list-x11-* sub-commands, to determine the available models, layouts,
Expand Down Expand Up @@ -113,3 +113,6 @@ ssh_pwauth: true
#- [ ls, -l, / ]
#- [ sh, -xc, "echo $(date) ': hello world!'" ]
#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ]

runcmd:
- [ touch, /etc/cloud/cloud-init.disabled ]
32 changes: 16 additions & 16 deletions install_opi5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,42 @@ chmod +x install.sh

sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=0-7/g' install.sh

./install.sh -n -q
./install.sh -m -q
rm install.sh

echo "Installing additional things"

apt-get install --yes --quiet network-manager net-tools libatomic1

# set NetworkManager as the renderer in cloud-init and static ip
cp -f ./OPi5_CIDATA/network-config /boot/network-config
# let netplan create the config during cloud-init
rm -f /etc/netplan/00-default-nm-renderer.yaml

# set the hostname in cloud-init
sed -i 's/#hostname:.*/hostname: photonvision/' /boot/user-data
grep 'hostname:' /boot/user-data
# set NetworkManager as the renderer in cloud-init
cp -f ./OPi5_CIDATA/network-config /boot/network-config

# add run command to disable cloud-init after first boot
sed -i '$a\\nruncmd:\n- [ touch, /etc/cloud/cloud-init.disabled ]' /boot/user-data
tail /boot/user-data
# add customized user-data file for cloud-init
cp -f ./OPi5_CIDATA/user-data /boot/user-data

# tell NetworkManager not to wait for the carrier on ethernet, which can delay boot
# when the coprocessor isn't connected to the ethernet
cat > /etc/NetworkManager/conf.d/50-ignore-carrier.conf <<EOF
[main]
ignore-carrier=*
EOF
# cat > /etc/NetworkManager/conf.d/50-ignore-carrier.conf <<EOF
# [main]
# ignore-carrier=*
# EOF

# modify photonvision.service to wait for the network before starting
# this helps ensure that photonvision detects the network the first time it starts
# but it may cause a startup delay if the coprocessor isn't connected to a network
sed -i '/Description/aAfter=network-online.target' /etc/systemd/system/photonvision.service
sed -i 's/-n$//' /etc/systemd/system/photonvision.service
cat /etc/systemd/system/photonvision.service

# systemctl disable NetworkManager-wait-online.service
# networkd isn't being used, this causes an unnecessary delay
systemctl disable systemd-networkd-wait-online.service

apt-get install --yes --quiet libc6 libstdc++6
# the bluetooth service isn't needed and causes a delay at boot
systemctl disable ap6275p-bluetooth.service

apt-get install --yes --quiet libc6 libstdc++6

if [ $(cat /etc/lsb-release | grep -c "24.04") -gt 0 ]; then
# add jammy to apt sources
Expand Down

0 comments on commit db8325c

Please sign in to comment.