Skip to content

Task: goat-setup-script.sh #2

Description

@ismith

@ismith wrote a bash script that automates a bunch of the software setup to be done if you're using:

  • debian trixie
  • rpi 3b+
  • pican 2

TODO:

  • can any of the trixie updates be integrated into the existing doc?
    • hopefully we can detect - auto or manually - when the "old way" is right vs the "new way" GOAT found on 2026-05-03
  • some of it (maybe just passwordless sudo, i'm not sure) is GOAT-specific, doesn't need upstreaming, but should be preserved for our research
  • can any of this be turned into a debian package for easier install/setup?
the bash script
#!/bin/bash
set -euxo pipefail

# Tested on debian trixie

# Allow sudo with no password
echo 'pi ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/010_pi-nopasswd
sudo chmod 0440 /etc/sudoers.d/010_pi-nopasswd

# Install vim, screen, git (our preferences) and canutils, python3-can (open-rnet's requirements)
# Note: use apt to install python-can, not pip, because python packages on raspbian/trixie default to 'externally managed'.
sudo apt update && sudo apt install -y \
  vim screen git \
  can-utils python3-can

# Firmware config/overlay for the PiCAN 2
# Note: -overlay suffix not needed in modern kernel, and spi-bcm2835 not needed at all
cat <<EOF >> /boot/firmware/config.txt

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835
EOF

# Make the can0 network device work on boot, don't need to manually add each time
touch /etc/systemd/network/80-can0.network
cat <<EOF >> /etc/systemd/network/80-can0.network
[Match]
Name=can0

[CAN]
BitRate=125000
EOF
sudo systemctl enable systemd-networkd

# If we don't already have can2RNET, clone it
[ ! -d ~/can2RNET ] && git clone https://github.com/redragonx/can2RNET.git ~/can2RNET

cat <<EOF
=======================
WHAT'S NEXT?
=======================
1. Reboot:
sudo reboot

2. Check: if you run

dmesg | grep -i can
dmesg | grep -i mcp

You should see messages about mcp251x registering successfully.
=======================
EOF

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions