Update setup scripts

This commit is contained in:
Satu Koskinen 2022-10-11 09:17:13 +03:00
parent 2af755c4fc
commit 1e7048717a
4 changed files with 74 additions and 17 deletions

View File

@ -1,25 +1,68 @@
#!/bin/sh
#!/bin/bash
# Copy the files to /home/pi
cd /home/pi
cp -R /boot/hydrophonitor .
cd hydrophonitor
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
# Setup audio
sh scripts/setup-audio.sh
echo
echo "### Setup audio"
echo
cd "$DIR_PATH" && sh hydrophonitor/scripts/setup-audio.sh
# Setup GPS
sh scripts/setup-gps.sh
echo
echo "### Setup GPS"
echo
cd "$DIR_PATH" && sh hydrophonitor/scripts/setup-gps.sh
# Setup depth sensor
sh scripts/setup-pressure-depth.sh
echo
echo "### Setup depth recording"
echo
# Setup cron job to start the recordings at boot
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
echo "@reboot root /home/pi/hydrophonitor/scripts/start-all.sh" | sudo tee -a $CRON_FILE
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
sudo reboot
echo
echo "### Setup ready, run 'sudo reboot' to apply all changes"
echo

View File

@ -1,7 +1,9 @@
#!/bin/sh
#!/bin/bash
echo "Setting up audio recording"
# Install packages
sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-dev jackd2
sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-dev
# Get ID and number of the USB audio device
card_number=$(aplay -l | grep -i usb | grep -i audio | cut -d ' ' -f 2 | cut -d ':' -f 1)
@ -9,7 +11,7 @@ card_number=$(aplay -l | grep -i usb | grep -i audio | cut -d ' ' -f 2 | cut -d
# Change default audio device
sudo touch /etc/asound.conf
sudo cat << EOF | sudo tee -a /etc/asound.conf
sudo cat << EOF | sudo tee /etc/asound.conf
pcm.!default {
type plug
slave {
@ -22,3 +24,5 @@ ctl.!default {
card $card_number
}
EOF
cd hydrophonitor/audio-logger && cargo build --release

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "Setting up GPS recording"
sudo apt-get update && sudo apt-get install -y \
gpsd gpsd-clients
@ -12,5 +14,4 @@ sudo gpsd ${device} -F /var/run/gpsd.sock
sudo sed -i "s|DEVICES=\"\"|DEVICES=\"${device}\"|g" /etc/default/gpsd
echo "START_DAEMON=\"true\"" | sudo tee -a /etc/default/gpsd
sudo grep -qxF "START_DAEMON=\"true\"" /etc/default/gpsd || echo "START_DAEMON=\"true\"" | sudo tee -a /etc/default/gpsd

View File

@ -1 +1,10 @@
#!/bin/sh
echo "Setting up depth recording"
# Enable i2c bus on Raspberry Pi
sudo raspi-config nonint do_i2c 0
# Install packages
sudo apt-get update && sudo apt-get install -y i2c-tools python3-pip
sudo pip3 install Adafruit-Blinka adafruit-circuitpython-ads1x15