Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b574533
move machine ID to /etc/sensorgnome_id
tve Oct 17, 2021
f82b207
fix locations of files now found in /data
tve Oct 17, 2021
05e030a
fix socket.io API to work with version 4.x
tve Oct 17, 2021
693fa13
use NPM package.json to install javascript dependencies
tve Oct 17, 2021
ec500f2
add .gitignore to block node_modules
tve Oct 17, 2021
d85ebc1
update readme
tve Oct 17, 2021
8deb9f5
move non-source files out of source dir
tve Nov 2, 2021
9182da4
rename master->main and move files from master/ to src/
tve Nov 3, 2021
6511508
add debian packaging
tve Nov 3, 2021
772824b
add github action to build package
tve Nov 3, 2021
98cf839
change s3 upload bucket
tve Nov 4, 2021
30d9a5a
add gitignore
tve Nov 4, 2021
832b903
switch gen packages from npm install to update
tve Nov 4, 2021
65282e2
switch S3 upload path to branch/tag name
tve Nov 5, 2021
5cf5e4d
Fix packaging and service scripts
tve Nov 5, 2021
8fd06e6
Fix installation
tve Nov 6, 2021
c70b410
add sqlite3 dependency
tve Nov 7, 2021
d9bf73e
find_tags_unifile is now in /usr/bin
tve Nov 7, 2021
ae9a8ef
add logging to tag finder runner
tve Nov 7, 2021
a65796a
fix symlink in /media/SD_card
tve Nov 7, 2021
9824723
Fix display of software build
tve Nov 7, 2021
9983e81
Fix display of attached devices
tve Nov 7, 2021
472c94b
Fix dependencies in service script
tve Nov 8, 2021
18b56c0
Restart on reinstall
tve Nov 8, 2021
3cdb86f
Add support for CTT/Cornell tags
tve Nov 8, 2021
8d4385e
Move initial deployment.txt to /boot
tve Nov 10, 2021
9885f82
Improve package annotation
tve Nov 10, 2021
e2a0414
Change get-usb-hub-devices to python
tve Nov 10, 2021
345af98
add doit script
tve Nov 10, 2021
30e02f6
Tweak device listing
tve Nov 10, 2021
594a780
Update .gitignore
tve Nov 10, 2021
25ef790
Change package version time cut-off
tve Nov 11, 2021
7e4761c
Show port nums >10 in red
tve Nov 11, 2021
747fe53
Fix display of usb port paths
tve Nov 11, 2021
e5bf528
Chase udev issue
tve Nov 15, 2021
b4a6921
Add request logging
tve Nov 16, 2021
489e32e
Make display of storage devices work
tve Nov 16, 2021
8023245
Tweak doit
tve Nov 16, 2021
a85d931
Add default tag database, fixes #4
tve Nov 17, 2021
94b64f1
reduce web server logging
tve Nov 17, 2021
ae4ce6e
Add comment about CTT V2 receivers
tve Nov 22, 2021
370c4ad
Improve display of GPS info
tve Nov 24, 2021
8fb8f2c
Try to speed-up exit
tve Nov 24, 2021
28ba066
Fix install of config files in /boot and /data/config
tve Nov 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build package

on: [push]

env:
# Upload to AWS uses OIDC for federated auth:
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
S3_PATH: motus-builds/${{github.repository}}
S3_REGION: us-east-2
AWS_ROLE: arn:aws:iam::635201719205:role/Github-actions-motus

permissions:
id-token: write
contents: write

jobs:
build-all:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: .

# use branch or tag name in S3 upload path
- run: echo GIT_REF=${{github.ref}} | sed -e 's;refs/[^/]*/;;' >>$GITHUB_ENV

- name: Generate .deb packages
run: ./gen-package.sh
shell: bash
- run: ls -ls packages

# Upload github artifacts for debugging purposes
- uses: actions/upload-artifact@v2
with:
name: deb-packages
path: packages

- name: Configure AWS Credentials
# See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: ${{env.AWS_ROLE}}
role-session-name: GithubActionsMotus
aws-region: ${{ env.S3_REGION }}

- name: Upload .debs to AWS S3 repo
run: |
aws s3 sync --acl public-read packages s3://${{env.S3_PATH}}/$GIT_REF/

- name: Create annotation with link to packages on S3
run: |
echo "https://${{env.S3_PATH}}/$GIT_REF/"
echo "::notice title=Packages::https://${{env.S3_PATH}}/$GIT_REF/"
for p in $(cd packages; echo *.deb); do
echo "::notice title=Package::https://${{env.S3_PATH}}/$GIT_REF/$p"
done
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.deb
build-temp
node_modules
master.sh
prep.sh
9 changes: 9 additions & 0 deletions DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: sg-control
Version: 0
Architecture: armhf
Essential: no
Depends: nodejs, sqlite3
Homepage: https://github.com/sensorgnome/sensorgnome-control
Maintainer: TvE ([email protected])
Description: Sensorgnome main control process
Orchestrates all tag detection, processing, transmission and web activities.
43 changes: 43 additions & 0 deletions DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /bin/bash -e
echo "Running sg-control postinst in $(pwd)"
SG=/opt/sensorgnome # would be nice to derive that from some env var...

# install deployment.txt and tag database if not there
SRC=$SG/templates
for f in deployment.txt SG_tag_database.sqlite; do
if [[ -d /data/config ]]; then
# $SRC/$f exists, so this must be an update, put it there unless it exists
[[ -f /data/config/$f ]] || cp $SRC/$f /data/config
else
# $SRC/$f does not exist, so this must be a fresh install, put it into /boot
# it will be copied to $SRC on first boot
[[ -f /boot/$f ]] || cp $SRC/$f /boot
fi
done

# enable and start/restart units
for U in sg-control; do
# code from debhelper's postinst-systemd-enable template
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask $U >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled $U; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable $U.service || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state $U >/dev/null || true
fi
fi

# Restart service, if it is running
systemctl daemon-reload
if systemctl is-active --quiet $U.service; then
echo "Restarting $U.service"
systemctl restart $U.service
fi
done
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# sensorgnome-control
Master control process for a sensorgnome field computer.

This repo used to hold both control and [support](https://github.com/sensorgnome-org/sensorgnome-support) software, but was split into two repos.
Main control process for a sensorgnome field computer.

The main control process consists of a JavaScript node.js application found in the src
directory. Npm is used to install all the dependencies: run `npm install`.

The `gen-package.sh` script produces a debian package that includes the application, the
systemd service file, and all the javascript dependencies (i.e., `npm install` is run as part
of the packaging process). The reason to bundle the dependencies is so the deb can be carried to
a station on a flash stick and used to upgrade without requiring an internet connection.

History: this repo used to hold both control and
[support](https://github.com/sensorgnome-org/sensorgnome-support)
software, but was split into two repos.
Also the term "master" has been replaced by "main".
Binary file added SG_tag_database.sqlite
Binary file not shown.
File renamed without changes.
7 changes: 7 additions & 0 deletions doit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash -e
SG_HOST=${1:-sg-eth}
./gen-package.sh
PKG=$(ls -r packages | head -1)
scp packages/$PKG pi@$SG_HOST:
ssh pi@$SG_HOST sudo apt install --reinstall ./$PKG
#ssh pi@$SG_HOST sudo systemctl restart sg-control
28 changes: 28 additions & 0 deletions gen-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/bash -e
DESTDIR=build-temp
sudo rm -rf $DESTDIR
mkdir $DESTDIR

# npm update to pull in the latest versions of all dependencies
(cd src; npm --no-fund update)

# install the control application files as user pi=1000
SG=$DESTDIR/opt/sensorgnome
install -d $SG/control
cp -r src/* $SG/control
sudo chown -R 1000:1000 $SG/control

# install default deployment file and tag database into templates dir
sudo install -d $DESTDIR/opt/sensorgnome/templates -o 1000 -g 1000
sudo install -m 644 deployment.txt SG_tag_database.sqlite $DESTDIR/opt/sensorgnome/templates

# service file should be owned by root
sudo install -d $DESTDIR/etc/systemd/system -o 0 -g 0
sudo install -m 644 -o 0 -g 0 *.service $DESTDIR/etc/systemd/system

cp -r DEBIAN $DESTDIR
sed -e "/^Version/s/:.*/: $(TZ=PST8PDT date +%Y.%j)/" -i $DESTDIR/DEBIAN/control # set version: YYYY.DDD
mkdir -p packages
dpkg-deb --build $DESTDIR packages
# dpkg-deb --contents packages
ls -lh packages
File renamed without changes.
3 changes: 3 additions & 0 deletions get_clocks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# get_clocks

This little program does not seem to be used.
File renamed without changes.
145 changes: 0 additions & 145 deletions master/gestures.js

This file was deleted.

Loading