2025-08-25 11:21:47 -07:00
# AREDN Firmware Sync Script
2025-08-25 10:44:16 -07:00
2025-08-25 11:21:47 -07:00
This script mirrors the [AREDN firmware repository ](https://downloads.arednmesh.org/ ), patches the firmware site config to use a local mesh URL, and regenerates JSON indexes. See [Creating a Local AREDN® Software Server ](https://docs.arednmesh.org/en/latest/arednHow-toGuides/local-software-source.html ).
2025-08-25 12:00:35 -07:00
This script was designed for use by **Disaster Response Communications & Information Technology (DRCIT)** but is freely reusable by other hams/groups.
2025-08-25 11:21:47 -07:00
---
2025-08-25 12:00:56 -07:00
## 🚀 Quick Start
2025-08-25 11:21:47 -07:00
```bash
# 1. Clone this repo
git clone https://drcit.dev/DRCIT/aredn.git
cd aredn
2025-08-25 12:00:35 -07:00
# 2. Edit aredn_sync.sh variables for your node
nano aredn_sync.sh # set ROOT, LOG, NEW_URL
2025-08-25 11:21:47 -07:00
# 3. Make it executable
2025-08-25 12:07:58 -07:00
install -m 755 aredn_sync.sh ~/.local/bin/
2025-08-25 11:21:47 -07:00
2025-08-25 12:27:12 -07:00
# 4. Test once manually (Below assumes you've installed the script in ~/.local/bin folder).
2025-08-25 12:00:35 -07:00
~/.local/bin/aredn_sync.sh
2025-08-25 11:21:47 -07:00
2025-08-25 12:10:48 -07:00
# 5. Add cron (this example is daily)
2025-08-25 12:00:35 -07:00
crontab -e
2025-08-25 11:21:47 -07:00
# add this line:
2025-08-25 12:10:48 -07:00
0 0 * * * ~/.local/bin/aredn_sync.sh >> ~/.local/logs/aredn.log 2>& 1
2025-08-25 11:21:47 -07:00
# 6. Add logrotate rule
sudo tee /etc/logrotate.d/aredn-sync < < 'EOF'
2025-08-25 11:44:42 -07:00
su < user > < group >
/< home path > /.local/logs/aredn.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 0640 < user > < group >
}
EOF
```
2025-08-25 12:19:29 -07:00
Done ✅ — your mirror will now stay up to date automatically. Replace `<user>` and `<group>` with actual user & group (usually `drcit` `drcit` ), and replace any `<paths>` with the correct *absolute* path (e.g. `/home/drcit/.local/logs/aredn.log` )
2025-08-25 11:44:42 -07:00
---
## 🔧 How it works
1. **Sync** : runs `rsync` to mirror upstream firmware files into `$ROOT` .
2. **Patch** : replaces the default firmware URL in `afs/www/config.js` with your local mesh URL (`$NEW_URL`).
3. **Collect** : runs `afs/misc/collect.py` to regenerate JSON indexes.
4. **Log** : everything is written to `~/.local/logs/aredn.log` .
---
## ⚙️ Variables to Edit
2025-08-25 12:07:58 -07:00
At the top of `aredn_sync.sh` , adjust these for your environment:
2025-08-25 11:44:42 -07:00
```bash
ROOT="$HOME/< path to root folder > /aredn" # mirror root
AFS="$ROOT/afs" # firmware site files
LOG="$HOME/.local/logs/aredn.log" # log path
UPSTREAM="downloads.arednmesh.org::aredn_firmware" # rsync source
NEW_URL="http://n2drc-ls1.local.mesh/" # mesh URL to inject
```
2025-08-25 12:19:29 -07:00
Replace any `<paths>` with the correct path (e.g. '$HOME/docker/fileserver/files/aredn').
2025-08-25 11:44:42 -07:00
---
## 📅 Cron Job
To keep your mirror current, run the script daily:
```cron
2025-08-25 12:07:58 -07:00
0 0 * * * ~/.local/bin/aredn_sync.sh >> ~/.local/logs/aredn.log 2>& 1
2025-08-25 11:44:42 -07:00
```
---
## 📂 Log Rotation
To prevent logs from growing indefinitely, add `/etc/logrotate.d/aredn-sync` :
```conf
su < user > < group >
2025-08-25 12:00:35 -07:00
/< home path > /.local/logs/aredn.log {
2025-08-25 11:21:47 -07:00
daily
rotate 7
compress
delaycompress
missingok
notifempty
2025-08-25 11:44:42 -07:00
create 0640 < user > < group >
2025-08-25 11:21:47 -07:00
}
2025-08-25 11:44:42 -07:00
```
2025-08-25 12:28:14 -07:00
This rotates logs daily, keeps 7 days, and compresses older logs. Replace `<user>` and `<group>` with actual user & group (usually `drcit` `drcit` ), and replace any `<paths>` with the correct *absolute* path (e.g. `/home/drcit/.local/logs/aredn.log` ). You can test your logrotate file with `sudo logrotate -f /etc/logrotate.d/aredn-sync` to ensure it’ s valid.
2025-08-25 11:44:42 -07:00
---
## 📜 License
This project is licensed under the [MIT License ](LICENSE ).
You are free to use, modify, and share this script. Attribution to **DRCIT** is appreciated.