From ef5c7d03cc879546c9a4ea88a0187b6391b66ee7 Mon Sep 17 00:00:00 2001 From: Satu Koskinen Date: Tue, 11 Oct 2022 09:19:01 +0300 Subject: [PATCH] Switch start scripts to use bash, clean up --- scripts/start-all.sh | 16 ++++++++++------ scripts/start-audio.sh | 9 +++------ scripts/start-gps.sh | 10 +++------- scripts/start-pressure-depth.sh | 8 +++----- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 905e206..d6c4c21 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -1,15 +1,19 @@ -#!/bin/sh +#!/bin/bash + +# Print all commands to standard output +set -x + +SCRIPT_PATH=/home/pi/hydrophonitor/scripts # Export the configuration values -. /home/pi/hydrophonitor/scripts/export-config-values.sh +$SCRIPT_PATH/export-config-values.sh # Create output directory OUTPUT_DIR=$BASE_DIR_PATH/$(date +"%Y-%m-%d_%H-%M-%S_output") -mkdir -p $OUTPUT_DIR/audio +echo "Create output directory $OUTPUT_DIR" +mkdir -p "$OUTPUT_DIR"/audio # Sleep for a little to wait for GPS and sound card to be ready sleep 10 -echo "(export OUTPUT_DIR=$OUTPUT_DIR; /home/pi/hydrophonitor/scripts/start-audio.sh & /home/pi/hydrophonitor/scripts/start-gps.sh)" >> $OUTPUT_DIR/log.txt 2>&1 - -(export OUTPUT_DIR=$OUTPUT_DIR; /home/pi/hydrophonitor/scripts/start-audio.sh & /home/pi/hydrophonitor/scripts/start-gps.sh) >> $OUTPUT_DIR/log.txt 2>&1 +(export OUTPUT_DIR=$OUTPUT_DIR; $SCRIPT_PATH/start-audio.sh & $SCRIPT_PATH/start-gps.sh & $SCRIPT_PATH/start-pressure-depth.sh) >> "$OUTPUT_DIR"/log.txt 2>&1 diff --git a/scripts/start-audio.sh b/scripts/start-audio.sh index 858a3b3..4af6078 100755 --- a/scripts/start-audio.sh +++ b/scripts/start-audio.sh @@ -1,9 +1,8 @@ -#!/bin/sh +#!/bin/bash # Export the configuration values -. /home/pi/hydrophonitor/scripts/export-config-values.sh +/home/pi/hydrophonitor/scripts/export-config-values.sh -AUDIO_TARGET_PATH="/home/pi/hydrophonitor/audio-logger/target/release" AUDIO_TARGET_EXECUTABLE="audio" OPTIONS="rec \ @@ -15,6 +14,4 @@ OPTIONS="rec \ --buffer-size 1024 \ alsa" -echo "cd $AUDIO_TARGET_PATH && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS" - -cd $AUDIO_TARGET_PATH && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS +cd /home/pi/hydrophonitor/audio-logger/target/release && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS diff --git a/scripts/start-gps.sh b/scripts/start-gps.sh index 0afdc86..f8a4a19 100755 --- a/scripts/start-gps.sh +++ b/scripts/start-gps.sh @@ -1,12 +1,8 @@ -#!/usr/bin/sh +#!/bin/bash # Export the configuration values -. /home/pi/hydrophonitor/scripts/export-config-values.sh - -GPS_EXECUTABLE_PATH="/home/pi/hydrophonitor/gps-logger" +/home/pi/hydrophonitor/scripts/export-config-values.sh OPTIONS="--output $OUTPUT_DIR --interval $GPS_INTERVAL" -echo "cd $GPS_EXECUTABLE_PATH && python record-gps.py $OPTIONS" - -cd $GPS_EXECUTABLE_PATH && python record-gps.py $OPTIONS +cd /home/pi/hydrophonitor/gps-logger && python record-gps.py $OPTIONS diff --git a/scripts/start-pressure-depth.sh b/scripts/start-pressure-depth.sh index c2071b3..5c29960 100644 --- a/scripts/start-pressure-depth.sh +++ b/scripts/start-pressure-depth.sh @@ -1,10 +1,8 @@ -#!/usr/bin/sh +#!/bin/bash # Export the configuration values -. /home/pi/hydrophonitor/scripts/export-config-values.sh - -DEPTH_EXECUTABLE_PATH="/home/pi/hydrophonitor/depth-logger" +/home/pi/hydrophonitor/scripts/export-config-values.sh OPTIONS="--output $OUTPUT_DIR --interval $DEPTH_INTERVAL" -cd $DEPTH_EXECUTABLE_PATH && python record-depth.py $OPTIONS +cd /home/pi/hydrophonitor/depth-logger && python record-depth.py $OPTIONS