Reorganize config & script files, set HOME_PATH and SCRIPT_PATH in setup-raspberry-pi.sh
This commit is contained in:
parent
81b83f2a14
commit
e19903bb98
@ -1,68 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
DIR_PATH=$HOME
|
|
||||||
BOOT_DIR_PATH=/boot/hydrophonitor
|
|
||||||
|
|
||||||
# Copy the files to DIR_PATH
|
|
||||||
echo
|
|
||||||
echo "### Copy files to $DIR_PATH"
|
|
||||||
echo
|
|
||||||
|
|
||||||
mkdir -p "$DIR_PATH"
|
|
||||||
cd "$DIR_PATH"
|
|
||||||
cp -R $BOOT_DIR_PATH/ .
|
|
||||||
|
|
||||||
# Install the Rust toolchain
|
|
||||||
echo
|
|
||||||
echo "### Install the Rust toolchain"
|
|
||||||
echo
|
|
||||||
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
|
|
||||||
# Install some developer tools
|
|
||||||
echo
|
|
||||||
echo "### Install some developer tools"
|
|
||||||
echo
|
|
||||||
|
|
||||||
sudo apt-get update && sudo apt-get install -y build-essential python3-pip
|
|
||||||
|
|
||||||
# Setup audio
|
|
||||||
echo
|
|
||||||
echo "### Setup audio"
|
|
||||||
echo
|
|
||||||
|
|
||||||
cd "$DIR_PATH" && sh hydrophonitor/scripts/setup-audio.sh
|
|
||||||
|
|
||||||
# Setup GPS
|
|
||||||
echo
|
|
||||||
echo "### Setup GPS"
|
|
||||||
echo
|
|
||||||
|
|
||||||
cd "$DIR_PATH" && sh hydrophonitor/scripts/setup-gps.sh
|
|
||||||
|
|
||||||
# Setup depth sensor
|
|
||||||
echo
|
|
||||||
echo "### Setup depth recording"
|
|
||||||
echo
|
|
||||||
|
|
||||||
cd "$DIR_PATH" && sh hydrophonitor/scripts/setup-pressure-depth.sh
|
|
||||||
|
|
||||||
# Set up cron job to start the recordings at boot
|
|
||||||
echo
|
|
||||||
echo "### Set up a cron job to start the recordings at boot"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# USER=$(whoami)
|
|
||||||
CRON_FILE=/etc/crontab
|
|
||||||
CRON_COMMAND="@reboot root $DIR_PATH/hydrophonitor/scripts/start-all.sh 2>&1 >> $BOOT_DIR_PATH/log.txt"
|
|
||||||
|
|
||||||
# Append command to cron file only if it's not there yet
|
|
||||||
sudo grep -qxF "$CRON_COMMAND" $CRON_FILE || echo "$CRON_COMMAND" | sudo tee -a $CRON_FILE
|
|
||||||
|
|
||||||
# Reboot
|
|
||||||
echo
|
|
||||||
echo "### Setup ready, run 'sudo reboot' to apply all changes"
|
|
||||||
echo
|
|
@ -17,5 +17,6 @@ DEPTH_INTERVAL=5
|
|||||||
|
|
||||||
TRY_MOUNT_SSD=true
|
TRY_MOUNT_SSD=true
|
||||||
|
|
||||||
DEFAULT_BASE_DIR_PATH=/home/pi/recordings
|
HOME_PATH=/home/pi
|
||||||
BASE_DIR_PATH=/home/pi/data
|
DEFAULT_OUTPUT_PATH=$HOME_PATH/recordings
|
||||||
|
OUTPUT_PATH=$HOME_PATH/data
|
@ -27,4 +27,4 @@ ctl.!default {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd hydrophonitor/audio-logger && cargo build --release
|
cd $HOME/hydrophonitor/audio-logger && cargo build --release
|
||||||
|
@ -6,7 +6,7 @@ echo "Setting up GPS recording"
|
|||||||
|
|
||||||
sudo apt-get update && sudo apt-get install -y gpsd gpsd-clients
|
sudo apt-get update && sudo apt-get install -y gpsd gpsd-clients
|
||||||
|
|
||||||
sudo pip install -r /home/pi/hydrophonitor/gps-logger/requirements.txt
|
sudo pip install -r $HOME/hydrophonitor/gps-logger/requirements.txt
|
||||||
|
|
||||||
sudo systemctl stop gpsd.socket
|
sudo systemctl stop gpsd.socket
|
||||||
sudo systemctl disable gpsd.socket
|
sudo systemctl disable gpsd.socket
|
||||||
|
@ -10,4 +10,4 @@ sudo raspi-config nonint do_i2c 0
|
|||||||
# Install packages
|
# Install packages
|
||||||
sudo apt-get update && sudo apt-get install -y i2c-tools python3-pip
|
sudo apt-get update && sudo apt-get install -y i2c-tools python3-pip
|
||||||
|
|
||||||
sudo pip install -r /home/pi/hydrophonitor/depth-logger/requirements.txt
|
sudo pip install -r $HOME/hydrophonitor/depth-logger/requirements.txt
|
||||||
|
81
scripts/setup-raspberry-pi.sh
Normal file
81
scripts/setup-raspberry-pi.sh
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
DIR_PATH=$HOME
|
||||||
|
BOOT_DIR_PATH=/boot/hydrophonitor
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "### Update file paths in config and start script files"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Update hydrophonitor-config.txt HOME_PATH to the current user's home
|
||||||
|
sudo sed -i "s|^HOME_PATH=.*$|HOME_PATH=$HOME|" $BOOT_DIR_PATH/hydrophonitor_config.txt
|
||||||
|
|
||||||
|
# Update script path in start scripts to the current user's home
|
||||||
|
sudo sed -i "s|^SCRIPT_PATH=.*$|SCRIPT_PATH=$HOME/hydrophonitor/scripts|" $BOOT_DIR_PATH/scripts/start-all.sh
|
||||||
|
sudo sed -i "s|^SCRIPT_PATH=.*$|SCRIPT_PATH=$HOME/hydrophonitor/scripts|" $BOOT_DIR_PATH/scripts/start-audio.sh
|
||||||
|
sudo sed -i "s|^SCRIPT_PATH=.*$|SCRIPT_PATH=$HOME/hydrophonitor/scripts|" $BOOT_DIR_PATH/scripts/start-gps.sh
|
||||||
|
sudo sed -i "s|^SCRIPT_PATH=.*$|SCRIPT_PATH=$HOME/hydrophonitor/scripts|" $BOOT_DIR_PATH/scripts/start-pressure-depth.sh
|
||||||
|
|
||||||
|
# Copy the files to DIR_PATH
|
||||||
|
echo
|
||||||
|
echo "### Copy files to $DIR_PATH"
|
||||||
|
echo
|
||||||
|
|
||||||
|
mkdir -p "$DIR_PATH"
|
||||||
|
cd "$DIR_PATH"
|
||||||
|
cp -R $BOOT_DIR_PATH/ .
|
||||||
|
|
||||||
|
# Install some development tools
|
||||||
|
echo
|
||||||
|
echo "### Install some development tools"
|
||||||
|
echo
|
||||||
|
|
||||||
|
sudo apt-get update && sudo apt-get install -y build-essential python3-pip
|
||||||
|
|
||||||
|
# Install the Rust programming language toolchain
|
||||||
|
echo
|
||||||
|
echo "### Install the Rust toolchain"
|
||||||
|
echo
|
||||||
|
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
|
source "$HOME/.cargo/env"
|
||||||
|
|
||||||
|
# Setup audio
|
||||||
|
echo
|
||||||
|
echo "### Setup audio"
|
||||||
|
echo
|
||||||
|
|
||||||
|
cd "$DIR_PATH" && ./hydrophonitor/scripts/setup-audio.sh
|
||||||
|
|
||||||
|
# Setup GPS
|
||||||
|
echo
|
||||||
|
echo "### Setup GPS"
|
||||||
|
echo
|
||||||
|
|
||||||
|
cd "$DIR_PATH" && ./hydrophonitor/scripts/setup-gps.sh
|
||||||
|
|
||||||
|
# Setup depth sensor
|
||||||
|
echo
|
||||||
|
echo "### Setup depth recording"
|
||||||
|
echo
|
||||||
|
|
||||||
|
cd "$DIR_PATH" && ./hydrophonitor/scripts/setup-pressure-depth.sh
|
||||||
|
|
||||||
|
# Set up cron job to start the recordings at boot
|
||||||
|
echo
|
||||||
|
echo "### Set up a cron job to start the recordings at boot"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# USER=$(whoami)
|
||||||
|
CRON_FILE=/etc/crontab
|
||||||
|
CRON_COMMAND="@reboot root $DIR_PATH/hydrophonitor/scripts/start-all.sh 2>&1 > $BOOT_DIR_PATH/$(date +"%Y-%m-%dT%H-%M-%S")-log.txt"
|
||||||
|
|
||||||
|
# Append command to cron file only if it's not there yet
|
||||||
|
sudo grep -qxF "$CRON_COMMAND" $CRON_FILE || echo "$CRON_COMMAND" | sudo tee -a $CRON_FILE
|
||||||
|
|
||||||
|
# Reboot
|
||||||
|
echo
|
||||||
|
echo "### Setup ready, run 'sudo reboot' to apply all changes"
|
||||||
|
echo
|
@ -9,7 +9,7 @@ SCRIPT_PATH=/home/pi/hydrophonitor/scripts
|
|||||||
$SCRIPT_PATH/export-config-values.sh
|
$SCRIPT_PATH/export-config-values.sh
|
||||||
|
|
||||||
# Create output directory
|
# Create output directory
|
||||||
OUTPUT_DIR=$BASE_DIR_PATH/$(date +"%Y-%m-%d_%H-%M-%S_output")
|
OUTPUT_DIR=$OUTPUT_PATH/$(date +"%Y-%m-%d_%H-%M-%S_output")
|
||||||
echo "Create output directory $OUTPUT_DIR"
|
echo "Create output directory $OUTPUT_DIR"
|
||||||
mkdir -p "$OUTPUT_DIR"/audio
|
mkdir -p "$OUTPUT_DIR"/audio
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Export the configuration values
|
# Export the configuration values
|
||||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
SCRIPT_PATH=/home/pi/hydrophonitor/scripts
|
||||||
|
$SCRIPT_PATH/export-config-values.sh
|
||||||
|
|
||||||
AUDIO_TARGET_EXECUTABLE="audio"
|
AUDIO_TARGET_EXECUTABLE="audio"
|
||||||
|
|
||||||
@ -16,4 +17,4 @@ OPTIONS="rec \
|
|||||||
--buffer-size 1024 \
|
--buffer-size 1024 \
|
||||||
alsa"
|
alsa"
|
||||||
|
|
||||||
cd /home/pi/hydrophonitor/audio-logger/target/release && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS
|
cd $HOME_PATH/hydrophonitor/audio-logger/target/release && ./$AUDIO_TARGET_EXECUTABLE $OPTIONS
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Export the configuration values
|
# Export the configuration values
|
||||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
SCRIPT_PATH=/home/pi/hydrophonitor/scripts
|
||||||
|
$SCRIPT_PATH/export-config-values.sh
|
||||||
|
|
||||||
OPTIONS="--output $OUTPUT_DIR --interval $GPS_INTERVAL"
|
OPTIONS="--output $OUTPUT_DIR --interval $GPS_INTERVAL"
|
||||||
|
|
||||||
cd /home/pi/hydrophonitor/gps-logger && python record-gps.py $OPTIONS
|
cd $HOME_PATH/hydrophonitor/gps-logger && python record-gps.py $OPTIONS
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Export the configuration values
|
# Export the configuration values
|
||||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
SCRIPT_PATH=/home/pi/hydrophonitor/scripts
|
||||||
|
$SCRIPT_PATH/export-config-values.sh
|
||||||
|
|
||||||
OPTIONS="--output $OUTPUT_DIR --interval $DEPTH_INTERVAL"
|
OPTIONS="--output $OUTPUT_DIR --interval $DEPTH_INTERVAL"
|
||||||
|
|
||||||
cd /home/pi/hydrophonitor/depth-logger && python record-depth.py $OPTIONS
|
cd $HOME_PATH/hydrophonitor/depth-logger && python record-depth.py $OPTIONS
|
||||||
|
Loading…
Reference in New Issue
Block a user