- get user input for client config - update pulseaudio setup to run for all users - add op25 installer
163 lines
4.3 KiB
Bash
163 lines
4.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Check if the user is root
|
|
if [ "$EUID" -ne 0 ]
|
|
then echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
echo "----- Starting Radio Node Client Install Script -----"
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
# Copy the example env file
|
|
cp .env.example .env
|
|
|
|
echo "----- Collecting Setup Information -----"
|
|
|
|
# Ask the user for input and store in variables
|
|
echo "\t \\Client Config"
|
|
read -p "Enter Node Name: " nodeName
|
|
read -p "Enter Node IP: " nodeIP
|
|
read -p "Enter Node Port: " nodePort
|
|
read -p "Enter Node Location: " nodeLocation
|
|
read -p "Enter Audio Device ID: " audioDeviceID
|
|
|
|
# Update the values in the env file using sed
|
|
sed -i "s/^AUDIO_DEVICE_ID=\".*\"$/AUDIO_DEVICE_ID=\"$audioDeviceID\"/" .env
|
|
sed -i "s/^CLIENT_NAME=\".*\"$/CLIENT_NAME=\"$nodeName\"/" env
|
|
sed -i "s/^CLIENT_IP=\".*\"$/CLIENT_IP=\"$nodeIP\"/" env
|
|
sed -i "s/^CLIENT_PORT=.*$/CLIENT_PORT=$nodePort/" env
|
|
sed -i "s/^CLIENT_LOCATION=\".*\"$/CLIENT_LOCATION=\"$nodeLocation\"/" env
|
|
|
|
# Display the updated values
|
|
echo "----- Config file has been updated -----"
|
|
echo "----- Start of Config File -----"
|
|
cat env
|
|
echo "----- End of Config File -----"
|
|
|
|
echo "----- Getting Dependencies -----"
|
|
|
|
# Check for updates
|
|
apt-get update
|
|
|
|
# Install Node Repo
|
|
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
|
|
|
|
# Update the system
|
|
apt-get update
|
|
apt-get upgrade -y
|
|
|
|
# Install the necessary packages
|
|
apt-get install -y nodejs portaudio19-dev libportaudio2 libpulse-dev pulseaudio apulse python3 python3-pip git
|
|
|
|
# Install the node packages from the project
|
|
npm i
|
|
|
|
# Install the python packages needed for the bot
|
|
pip install -r ./pdab/requirements.txt
|
|
|
|
echo "----- Setting up Pulse Audio -----"
|
|
|
|
# Ensure pulse audio is running as system so the service can see the audio device
|
|
systemctl --global disable pulseaudio.service pulseaudio.socket
|
|
|
|
# Update the PulseAudio config to disable autospawning
|
|
sed -i 's/autospawn = .*$/autospawn = no/' /etc/pulse/client.conf
|
|
|
|
# Add the system PulseAudio service
|
|
echo "[Unit]
|
|
Description=PulseAudio system server
|
|
|
|
[Service]
|
|
Type=notify
|
|
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target" >> /etc/systemd/system/PulseAudio.service
|
|
|
|
# Add the root user to the pulse-access group
|
|
usermod -aG pulse-access root
|
|
usermod -aG pulse-access
|
|
|
|
# Enable the PulseAudio service
|
|
systemctl enable PulseAudio.service
|
|
|
|
# Start the PulseAudio service
|
|
systemctl start PulseAudio.service
|
|
|
|
echo "----- Setting up Radio Node Service -----"
|
|
|
|
# Setup bot service
|
|
echo "[Unit]
|
|
Description=Radio Node Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
WorkingDirectory=\"$SCRIPT_DIR\"
|
|
ExecStart=/usr/bin/node .
|
|
Restart=always
|
|
RestartDelay=10
|
|
Environment=\"DEBUG='client:*'\"
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target" >> /etc/systemd/system/RadioNode.service
|
|
|
|
echo "----- Setting up Radio Node Update Service -----"
|
|
|
|
# Setup bot update service
|
|
echo "[Unit]
|
|
Description=Radio Node Updater Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
WorkingDirectory=\"$SCRIPT_DIR\"
|
|
ExecStart=/usr/bin/bash update.sh
|
|
Restart=on-failure
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target" >> /etc/systemd/system/RadioNodeUpdater.service
|
|
|
|
# Install OP25
|
|
echo "----- Installing OP25 from Source -----"
|
|
# Clone the OP25 Git
|
|
cd /opt/
|
|
git clone https://github.com/boatbod/op25.git
|
|
cd op25
|
|
|
|
# Run the OP25 install script
|
|
bash ./install.sh
|
|
|
|
# Create the config file for the client or user to update later
|
|
cp /opt/op25/op25/gr-op25_repeater/apps/p25_rtl_example.json /opt/op25/op25/gr-op25_repeater/apps/radioNodeOP25Config.json
|
|
|
|
# Create the OP25 service
|
|
echo "[Unit]
|
|
Description=OP25 Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
WorkingDirectory=\"/opt/op25/op25/gr-op25_repeater/apps\"
|
|
ExecStart=./multi_rx.py -c radioNodeOP25Config.json
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target" >> /etc/systemd/system/OP25.service
|
|
|
|
echo "----- OP25 Setup Complete -----"
|
|
|
|
# Enable the OP25 service, don't start it though as the user needs to config
|
|
systemctl enable OP25.service
|
|
echo "----- OP25 Enabled; Please ensure to update the configuration and start the service -----"
|
|
|
|
# Move back to the directory that the user started in (might not be needed?)
|
|
cd $SCRIPT_DIR
|
|
|
|
# Enable the Radio Node service
|
|
systemctl enable RadioNode.service
|
|
|
|
# Start the Radio Nodeservice
|
|
echo "----- Starting the Radio Node Service -----"
|
|
systemctl start RadioNode.service
|
|
|
|
echo "----- Setup Complete! -----" |