Raspberry Pi 3 (Depricated) - OtagoPolytechnic/Cloudy-with-a-Chance-of-LoRa GitHub Wiki

How we are using this and why?

We decided to set up a Raspberry Pi (3) to be our gateway between our weather station and GitHub repo. This means we can deploy code to our sensors via it remotely to avoid restrictions on going up to the roof.

Set up - IP and SSH

We re-imaged the Pi and set up ssh keys with ssh-keygen -f raspberry<name>

From there we added them to the pi with scp and could ssh in.
image
scp -i <connect> <ssh-key>.pub [email protected]:~/etc/ssh/
We set a static ip by editing the /etc/network/interfaces file with:
image
This means we can set it up remotely and it shouldn't try to lease an ip via DHCP.

SSH via ssh -i <sshkey> [email protected]

Set up - GitHub connections

sudo apt update
sudo apt install git
image

Create a SSH key on the pi and add it to authorised keys, then add it to SSH keys on Github.
ssh-keygen -t rsa -f github-key -C "[email protected]"\ weather@OPweather:~/.ssh $ ssh-add ~/.ssh/github-key`

Follow instructions found here: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

Script and cron job

The following script runs once an hour with the cronjob, pulling from main.

#!/bin/bash

# Directory of Git repository
REPO_DIR="Cloudy-with-a-Chance-of-LoRa/"

# Change to the repository directory
cd ~
cd "$REPO_DIR" || exit

# Pull the latest changes from the remote repository
git pull origin main  # Branch name

cd ~
# Log
echo "$(date): Ran git pull" >> Documents/git-pull.log

Change the script to be executable with chmod +x /Documents/git-pull.sh Run the command crontab -e and add the following line:
0 * * * * /Documents/git-pull.sh This will run it once every hour.`

⚠️ **GitHub.com Fallback** ⚠️