Initial pigate packer builder

master
Ross McKelvie 2020-07-05 12:44:00 -05:00
commit 64637e11d7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 8EB61A6A89C47C3D
14 zmienionych plików z 419 dodań i 0 usunięć

6
.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,6 @@
output-arm-image
packer_cache
*.img
.DS_Store
wpa_supplicant.conf
sdr.conf

1
CNAME 100644
Wyświetl plik

@ -0,0 +1 @@
pigate.dev

18
Makefile 100644
Wyświetl plik

@ -0,0 +1,18 @@
all: clean build
clean:
rm -f output-arm-image/image
docker:
docker pull docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm
build: docker
docker run \
--rm \
--privileged \
-v ${PWD}:/build:ro \
-v ${PWD}/packer_cache:/build/packer_cache \
-v ${PWD}/output-arm-image:/build/output-arm-image \
-e PACKER_CACHE_DIR=/build/packer_cache \
packer-builder-arm build packer/aprs-pigate.json
mv output-arm-image/image output-arm-image/aprs-pigate.img

21
README.md 100644
Wyświetl plik

@ -0,0 +1,21 @@
# aprs-pigate
Prebuilt Raspberry Pi image for running a HAM radio APRS Internet Gateway using [direwolf] and [rtl-sdr]
## Usage
1. Download & Flash the image to an SD card
2. Insert SD card into a computer and load your wpa_supplicant.conf into boot if you are using wifi, and drop in a [pigate.conf](files/boot/pigate.conf) with your Callsign and password. You can use any custom direwolf config file here, enabling many different hardware configurations!
3. Insert into a raspberry pi with RTL-SDR plugged into USB, and power up! If everything was configured correctly, in about 5 minutes you should see it pop up on [aprs.fi].
## Contributing & Development
This project uses the following dependencies:
- Docker for Mac >= 2.3.2.0 (currently in edge)
- [`packer-build-arm-image`] in this repo I use the public docker image, but you can checkout this repo if you need to customize the build environment and build a custom docker image
- [`flash`] I use this to set a custom hostname on each flash, and is what is referenced in Makefile. However, you can flash the images using any conventional method.
Run `make build` to start building your first image.
[aprs.fi]: https://aprs.fi
[direwolf]: https://github.com/wb2osz/direwolf
[`flash`]: https://github.com/hypriot/flash
[`packer-build-arm-image`]: https://github.com/solo-io/packer-builder-arm-image/
[rtl-sdr]: https://www.rtl-sdr.com/

1
_config.yml 100644
Wyświetl plik

@ -0,0 +1 @@
theme: jekyll-theme-cayman

Wyświetl plik

@ -0,0 +1,27 @@
# We might not have an audio output device so set to null.
# We will override the input half on the command line.
ADEVICE null null
CHANNEL 0
# Set your callsign here
# I use SSID 10 for igate
MYCALL XXXXXX-10
# First you need to specify the name of a Tier 2 server.
# The current preferred way is to use one of these regional rotate addresses:
# noam.aprs2.net - for North America
# soam.aprs2.net - for South America
# euro.aprs2.net - for Europe and Africa
# asia.aprs2.net - for Asia
# aunz.aprs2.net - for Oceania
IGSERVER noam.aprs2.net
# You also need to specify your login name and passcode.
# http://apps.magicbug.co.uk/passcode/
IGLOGIN XXXXXX-10 1234
# Set your GPS coordinates for the igate to show up on the map
PBEACON sendto=IG delay=0:30 every=60:00 symbol="igate" overlay=R at=42^37.14N long=071^20.83W comment="RPi SDR DireWolf I-Gate https://pigate.dev"
# That's all you need for a receive only IGate which relays
# messages from the local radio channel to the global servers.

Wyświetl plik

@ -0,0 +1,39 @@
#cloud-config
# vim: syntax=yaml
#
hostname: aprs-pigate
manage_etc_hosts: true
apt_preserve_sources_list: true
resize_rootfs: true
growpart:
mode: auto
devices: ["/"]
ignore_growroot_disabled: false
users:
- name: pi
gecos: "DefaultUser"
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
groups: users
lock_passwd: false
ssh_pwauth: false
chpasswd: { expire: false }
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
- ntp
locale: "en_US.UTF-8"
timezone: "America/Chicago"
final_message: "The system is finally up, after $UPTIME seconds"
runcmd:
# Copy over user's predefined pigate conf to autostart
- [ mv, "/boot/pigate.conf", "/home/pi/pigate.conf"]
- [ chown, "pi:pi", "/home/pi/pigate.conf"]

Wyświetl plik

@ -0,0 +1,103 @@
# The top level settings are used as module
# and system configuration.
# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below
users:
- default
# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the above $user (debian)
disable_root: true
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false
# Example datasource config
# datasource:
# Ec2:
# metadata_urls: [ 'blah.com' ]
# timeout: 5 # (defaults to 50 seconds)
# max_wait: 10 # (defaults to 120 seconds)
datasource_list: [ NoCloud ]
# The modules that run in the 'init' stage
cloud_init_modules:
- migrator
- seed_random
- bootcmd
- write-files
- growpart
- resizefs
- disk_setup
- mounts
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- users-groups
- ssh
# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
- emit_upstart
- ssh-import-id
- locale
- set-passwords
- grub-dpkg
- apt-pipelining
- apt-configure
- ntp
- timezone
- disable-ec2-metadata
- runcmd
- byobu
# The modules that run in the 'final' stage
cloud_final_modules:
- package-update-upgrade-install
- fan
- puppet
- chef
- salt-minion
- mcollective
- rightscale_userdata
- scripts-vendor
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- ssh-authkey-fingerprints
- keys-to-console
- phone-home
- final-message
- power-state-change
# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
distro: debian
# Default user name + that default users groups (if added/used)
default_user:
name: debian
lock_passwd: True
gecos: Debian
groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
# Other config here will be given to the distro class and/or path classes
paths:
cloud_dir: /var/lib/cloud/
templates_dir: /etc/cloud/templates/
upstart_dir: /etc/init/
package_mirrors:
- arches: [default]
failsafe:
primary: http://deb.debian.org/debian
security: http://security.debian.org/
ssh_svcname: ssh

Wyświetl plik

@ -0,0 +1 @@
* * * * * pi /home/pi/dw-start-cron.sh >/dev/null 2>&1

Wyświetl plik

@ -0,0 +1,71 @@
#!/bin/bash
# Pre-modified version of dw-start.sh for headless CLI setup.
# Original: https://github.com/wb2osz/direwolf/blob/master/dw-start.sh
# Changes:
# - remove RUNMODE to force CLI always (helps for testing), remove GUI function
# - set DWCMD for CLI mode with RTL-SDR, create a separate file to pass to screen to work with Buster
# - remove initial sleep wait since we don't care about desktop
# - added logs to CLI command that pipe to LOGFILE instead of ignored.
# Run this from crontab periodically to start up
# Dire Wolf automatically.
# Location of the direwolf binary. Depends on $PATH as shown.
# change this if you want to use some other specific location.
# e.g. DIREWOLF="/usr/local/bin/direwolf"
DIREWOLF="direwolf"
DWCMD="/home/pi/rtl-dw-start.sh"
# Where will logs go - needs to be writable by non-root users
LOGFILE=/var/tmp/dw-start.log
#-------------------------------------
# Main functions of the script
#-------------------------------------
function CLI {
SCREEN=`which screen`
if [ $? -ne 0 ]; then
echo -e "Error: screen is not installed but is required for CLI mode. Aborting"
echo -e "Error: screen is not installed but is required for CLI mode. Aborting" >> $LOGFILE
exit 1
fi
echo "Direwolf in CLI mode start up"
echo "Direwolf in CLI mode start up" >> $LOGFILE
# Screen commands
# -d m :: starts the command in detached mode
# -S :: name the session
$SCREEN -L -d -m -S direwolf $DWCMD >> $LOGFILE
$SCREEN -list direwolf
$SCREEN -list direwolf >> $LOGFILE
echo "-----------------------"
echo "-----------------------" >> $LOGFILE
}
# -----------------------------------------------------------
# Main Script start
# -----------------------------------------------------------
# When running from cron, we have a very minimal environment
# including PATH=/usr/bin:/bin.
#
export PATH=/usr/local/bin:$PATH
#
# Nothing to do if Direwolf is already running.
#
a=`ps ax | grep direwolf | grep -vi -e bash -e screen -e grep | awk '{print $1}'`
if [ -n "$a" ]
then
#date >> /tmp/dw-start.log
#echo "Direwolf already running." >> $LOGFILE
exit
fi
# Main execution of the script
echo "Direwolf not running, starting." >> $LOGFILE
CLI

Wyświetl plik

@ -0,0 +1,3 @@
#!/bin/bash
rtl_fm -f 144.39M - | direwolf -c /home/pi/direwolf/sdr.conf -r 24000 -D 1 -

Wyświetl plik

@ -0,0 +1,61 @@
{
"variables": {},
"builders": [
{
"type": "arm-image",
"iso_url": "http://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2020-05-28/2020-05-27-raspios-buster-lite-armhf.zip",
"iso_checksum_type": "sha256",
"iso_checksum": "f5786604be4b41e292c5b3c711e2efa64b25a5b51869ea8313d58da0b46afc64",
"last_partition_extra_size": 524288000
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"touch /boot/ssh"
]
},
{
"type": "shell",
"script": "packer/base.sh"
},
{
"type": "file",
"source": "files/etc/cloud/cloud.cfg",
"destination": "/etc/cloud/cloud.cfg"
},
{
"type": "shell",
"script": "packer/rtl-sdr.sh"
},
{
"type": "file",
"source": "files/home/pi/dw-start-cron.sh",
"destination": "/home/pi/dw-start-cron.sh"
},
{
"type": "file",
"source": "files/home/pi/rtl-dw-start.sh",
"destination": "/home/pi/rtl-dw-start.sh"
},
{
"type": "file",
"source": "files/etc/cron.d/aprs-pigate",
"destination": "/etc/cron.d/aprs-pigate"
},
{
"type": "shell",
"inline": [
"chmod +x /home/pi/dw-start-cron.sh",
"chmod +x /home/pi/rtl-dw-start.sh",
"chown -R pi:pi /home/pi"
]
},
{
"type": "file",
"source": "files/boot/user-data.yaml",
"destination": "/boot/user-data"
}
]
}

39
packer/base.sh 100644
Wyświetl plik

@ -0,0 +1,39 @@
#!/bin/bash
set -x
# Locales, uncomment if user-data didn't fix these
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8;
# Set locale to en_US.UTF-8
cp /etc/locale.gen /etc/locale.gen.dist
sed -i -e "/^[^#]/s/^/#/" -e "/en_US.UTF-8/s/^#//" /etc/locale.gen
# American wifi
cp /var/cache/debconf/config.dat /var/cache/debconf/config.dat.dist
sed -i \
-e "s/Value: en_GB.UTF-8/Value: en_US.UTF-8/" \
-e "s/ locales = en_GB.UTF-8/ locales = en_US.UTF-8/" \
/var/cache/debconf/config.dat
locale-gen
update-locale LANG=en_US.UTF-8
# Update & Install packages
apt-get update -qq
apt-get upgrade -qy
apt-get install -qy --no-install-recommends \
vim \
git \
wget \
curl \
unzip \
cloud-init \
ssh-import-id \
screen
apt-get autoremove -y
# Link cloud-init config to VFAT /boot partition
mkdir -p /var/lib/cloud/seed/nocloud-net
ln -s /boot/user-data /var/lib/cloud/seed/nocloud-net/user-data
ln -s /boot/meta-data /var/lib/cloud/seed/nocloud-net/meta-data
ln -s /boot/network-config /var/lib/cloud/seed/nocloud-net/network-config

28
packer/rtl-sdr.sh 100644
Wyświetl plik

@ -0,0 +1,28 @@
#!/bin/bash
set -x
# Install packages
apt-get install -qy \
build-essential \
cmake \
libasound2-dev \
libusb-1.0-0-dev
# Direwolf Setup
cd /home/pi
git clone https://github.com/wb2osz/direwolf.git
cd direwolf
make
make install
make install-conf
# RTL-SDR Library
cd /home/pi
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON
make
make install
ldconfig