agent_gsm/setup/setup_agent_gsm.sh

76 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Refresh apt database
sudo apt update
# Installation directory
INSTALL_DIR=agent_gsm
# Re
GIT_SOURCE=https://git.sevana.biz/public/agent_gsm
# Install prerequisites
sudo apt install --assume-yes git mc python3 sox vim libffi-dev screen python3-pip
sudo pip3 install pyyaml sox pyrabbit soundfile dbus_python pexpect pydub requests python3-numpy
sudo pip3 install rabbitpy pydub
if [ -f "$INSTALL_DIR" ]; then
rm -rf "$INSTALL_DIR"
fi
# Anonymous cloning
git clone $GIT_SOURCE $INSTALL_DIR
# Go to cloned directory
cd $INSTALL_DIR
# Update config file
BACKEND_URL=""
PHONE_NAME=""
TASK_NAME=""
# Backend URL
read -p "Please specify backend URL [https://gsm.sevana.biz] ): " BACKEND_URL
BACKEND_URL=${BACKEND_URL:-"https://gsm.sevana.biz"}
# Device name
read -p "Please specify phone name (ex: moto_1): " PHONE_NAME
# Optional task name
read -p "Please specify expected task name (if this is answerer phone): " TASK_NAME
# Get a copy of config file from redist
cp config/agent.in.yaml config/agent.yaml
# Update mc settings to ease further work
mkdir -p ~/.config/mc
cp config/mc/ini ~/.config/mc
# Replace the values
if [[ $BACKEND_URL != "" ]]; then
sed -i "s|BACKEND|$BACKEND|" config/agent.yaml
fi
if [[ $PHONE_NAME != "" ]]; then
sed -i "s|PHONE_NAME|$PHONE_NAME|" config/agent.yaml
fi
sed -i "s|TASK_NAME|$TASK_NAME|" config/agent.yaml
# Update systemD unit file
cp config/systemd/agent_gsm.in.service config/systemd/agent_gsm.service
ABSOLUTE_INSTALL_DIR=`realpath .`
sed -i "s|ABSOLUTE_INSTALL_DIR|$ABSOLUTE_INSTALL_DIR|" config/systemd/agent_gsm.service
echo "Now the remaining prerequisites will be installed and system will reboot."
echo "You can connect the phone via Bluetooth after the reboot."
echo "Use the connect_phone.sh to ease the connection process. This script will ask you about Bluetooth MAC address and make attempt to pair & connect the phone. "
echo "Please run $INSTALL_DIR/run_node.sh to see if everything works ok."
echo "After you can use $INSTALL_DIR/config/systemd/agent_gsm.service to enable this work with systemD."
echo ""
# Run bootstrap app
./pi_bootstrap_bt.sh