aboutsummaryrefslogtreecommitdiffstats
path: root/radio.sh
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-08-08 15:27:24 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-08-08 15:27:24 +0200
commit9525224ac5f026ed2610902970cfc493ecdcc29a (patch)
treec40184129f6024965081c084b6bc443b3d6ec340 /radio.sh
downloaddab-scripts-9525224ac5f026ed2610902970cfc493ecdcc29a.tar.gz
dab-scripts-9525224ac5f026ed2610902970cfc493ecdcc29a.tar.bz2
dab-scripts-9525224ac5f026ed2610902970cfc493ecdcc29a.zip
Add scripts and example site
Diffstat (limited to 'radio.sh')
-rwxr-xr-xradio.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/radio.sh b/radio.sh
new file mode 100755
index 0000000..d475ce4
--- /dev/null
+++ b/radio.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Start the encoder for the radio
+
+# Declare radios to be an associative array
+declare -A radios
+
+source site/configuration.sh
+
+printerr() {
+ echo -e "\033[01;31m$1\033[0m"
+}
+
+printmsg() {
+ echo -e "\033[01;32m$1\033[0m"
+}
+
+script_pid=0
+sigint_trap() {
+ printerr "Got Ctrl-C, killing radio encoder script"
+ if [[ "$script_pid" != "0" ]] ; then
+ kill $script_pid
+ script_pid=0
+ wait
+ fi
+}
+
+set -e
+
+# check number of arguments
+if [[ "$#" < 1 ]] ; then
+ echo "Usage $0 radio-id"
+ echo "You must specify which radio to start"
+ exit 1
+fi
+
+RADIO=$1
+
+if [ ${radios[$RADIO]+_} ] ; then
+ COMMAND=${radios[$RADIO]}
+
+ trap sigint_trap SIGINT
+
+ # execute script
+ $COMMAND &
+ script_pid=$!
+ wait
+else
+ echo "Radio $RADIO not defined in configuration"
+ exit 1
+fi
+