From e7ef4f5fe076b2bac49dc592a1776c23cf809ee2 Mon Sep 17 00:00:00 2001 From: Kenneth Barbour Date: Mon, 31 Jan 2022 19:14:26 -0500 Subject: [PATCH] wxrx entry script --- completion.bash | 6 ++++ wxrx.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 completion.bash create mode 100755 wxrx.sh diff --git a/completion.bash b/completion.bash new file mode 100644 index 0000000..8cc7533 --- /dev/null +++ b/completion.bash @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# This is the tab-completion script for wxrx +# To use it, either: +# * source this file +# * symlink this file to `/etc/bash_completion.d/wxrx_completion.bash` +complete -W 'help predict record decode pase update schedule' wxrx diff --git a/wxrx.sh b/wxrx.sh new file mode 100755 index 0000000..11c4db6 --- /dev/null +++ b/wxrx.sh @@ -0,0 +1,78 @@ +#!/bin/sh +## +## __PROG__ [-h|--help] ... +prog="$0" +me=`basename "$prog"` +rootdir=$(dirname $(realpath $0)) +source ${rootdir}/lib/utils.sh + +# Lines starting with '##' are intended for usage documentation +function usage() { + grep '^##' "$prog" | sed -e 's/^##\s\?//' -e "s/__PROG__/$me/" 1>&2 +} + +# Like printf, but prints to stderr with prettier formatting if TTY +function logerr() { + if [ -t 2 ]; then + printf "$(tput setaf 1)ERROR$(tput sgr0) ${1}\n" ${@:2} 1>&2 + else + printf "${1}\n" ${@:2} 1>&2 + fi +} + +# is required +if [ -z "${1}" ]; then + logerr "A command is required" + usage + exit 1 +fi +command=${1} + +## Commands: +case "${1}" in + +## help Show this help message + 'help' | '-h' | '--help') + usage + exit + ;; + +## predict Predict future passes + 'predict') + shift + ${rootdir}/predict_passes.sh $@ + ;; + +## record Demodulate and record a signal + 'record') + shift + ${rootdir}/receive_pass.sh $@ + ;; + +## decode Decode images from a recorded APT signal + 'decode') + shift + ${rootdir}/build_images.sh $@ + ;; + +## pass Capture and decode a pass occuring NOW + 'pass') + printf "TODO\n" + ;; + +## update Update satellite telemetry + 'update') + shift + ${rootdir}/update_satellites.sh $@ + ;; +## schedule Schedule a future pass with `atd` + 'schedule') + printf "TODO\n" + ;; + + '*') + logerr "Unrecognized command ${1}" + usage + exit 1 + +esac