42 lines
1.3 KiB
Bash
Executable File
42 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Provision script for BrianBot
|
|
# These actions only occur on BrianBot's comma device.
|
|
|
|
# 1. Check the string in /data/params/d/DongleId
|
|
dongle_id=$(cat /data/params/d/DongleId)
|
|
if [[ ! $dongle_id == 90bb71a* ]]; then
|
|
echo "Invalid dongle ID."
|
|
exit 1
|
|
fi
|
|
|
|
echo "BrianBot dongle ID detected."
|
|
|
|
# 2. Check if ccrypt is installed, install if not
|
|
if ! command -v ccrypt >/dev/null 2>&1; then
|
|
echo "Installing ccrypt..."
|
|
sudo apt-get update
|
|
sudo apt-get install -y ccrypt
|
|
fi
|
|
|
|
# 3. Decrypt SSH keys if they have not been decrypted yet
|
|
if [ ! -f /data/openpilot/system/clearpilot/dev/id_rsa.pub ]; then
|
|
echo "Decrypting SSH keys..."
|
|
ccrypt -d -k "$dongle_id" /data/openpilot/system/clearpilot/dev/id_rsa.pub.ccrypt
|
|
ccrypt -d -k "$dongle_id" /data/openpilot/system/clearpilot/dev/id_rsa.ccrypt
|
|
ccrypt -d -k "$dongle_id" /data/openpilot/system/clearpilot/dev/reverse_ssh.ccrypt
|
|
fi
|
|
|
|
# 4. Ensure .ssh directory and keys exist
|
|
ssh_dir="/home/comma/.ssh"
|
|
if [[ ! -f "$ssh_dir/id_rsa" || ! -f "$ssh_dir/id_rsa.pub" ]]; then
|
|
echo "Setting up SSH directory and keys..."
|
|
mkdir -p "$ssh_dir"
|
|
cp /data/openpilot/system/clearpilot/dev/id_rsa /data/openpilot/system/clearpilot/dev/id_rsa.pub "$ssh_dir"
|
|
chmod 700 "$ssh_dir"
|
|
chmod 600 "$ssh_dir/id_rsa" "$ssh_dir/id_rsa.pub"
|
|
fi
|
|
|
|
echo "Script execution complete."
|
|
exit 0
|