#10 Updates
- Added check for updates at boot - Updated post update script to update OP25 and PDAB - Added initial makefile to replace the `setup.sh` - Added new test to make sure makefile builds - Renamed socket tests
This commit is contained in:
28
.gitea/workflows/DRBv3_Client_Build_test.yaml
Normal file
28
.gitea/workflows/DRBv3_Client_Build_test.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
name: DRB Client Makefile Build Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- name: Run setup process
|
||||
run: make -j4
|
||||
|
||||
- name: Start discord-radio-bot service
|
||||
run: systemctl start discord-radio-bot.service
|
||||
@@ -1,6 +1,12 @@
|
||||
name: Run Discord Radio Bot v3 Tests
|
||||
name: DRB Socket Communication Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
NODE_ENV: development
|
||||
123
client/Makefile
Normal file
123
client/Makefile
Normal file
@@ -0,0 +1,123 @@
|
||||
# Define variables
|
||||
CLIENT_DIR := client
|
||||
OP25_DIR := op25
|
||||
PDAB_DIR := discordAudioBot/pdab
|
||||
|
||||
.PHONY: all pre_flight_checks install_dependencies setup_pulse_audio install_node install_pdab generate_env_file add_systems_to_presets install_op25 set_permissions reboot
|
||||
|
||||
all: pre_flight_checks install_dependencies setup_pulse_audio install_node install_pdab generate_env_file add_systems_to_presets install_op25 set_permissions reboot
|
||||
|
||||
pre_flight_checks:
|
||||
# Exit on error
|
||||
set -e
|
||||
# Check if the script is run as root
|
||||
if [ "$(shell id -u)" -ne 0 ]; then \
|
||||
echo "Please run this script as root."; \
|
||||
exit 1; \
|
||||
fi
|
||||
# Check if the working directory is 'client' and contains package.json
|
||||
if [ ! -f "$(shell pwd)/$(CLIENT_DIR)/package.json" ]; then \
|
||||
echo "Error: Please make sure the working directory is 'client' and contains package.json."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
install_dependencies:
|
||||
# Install necessary dependencies
|
||||
apt update
|
||||
apt upgrade -y
|
||||
apt install -y nodejs portaudio19-dev libportaudio2 libpulse-dev pulseaudio apulse git ffmpeg git python3 python3-pip
|
||||
|
||||
setup_pulse_audio:
|
||||
# Setup Pulse Audio
|
||||
systemctl --global disable pulseaudio.service pulseaudio.socket
|
||||
sed -i 's/autospawn = .*$/autospawn = no/' /etc/pulse/client.conf
|
||||
echo "[Unit]" > /etc/systemd/system/PulseAudio.service
|
||||
echo "Description=PulseAudio system server" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "[Service]" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "Type=notify" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "[Install]" >> /etc/systemd/system/PulseAudio.service
|
||||
echo "WantedBy=multi-user.target" >> /etc/systemd/system/PulseAudio.service
|
||||
usermod -aG pulse-access root
|
||||
usermod -aG pulse-access pi
|
||||
systemctl enable PulseAudio.service
|
||||
systemctl stop PulseAudio.service
|
||||
|
||||
install_node:
|
||||
# Install Node Repo
|
||||
cpu_arch=$(shell uname -m)
|
||||
echo "Detected CPU Architecture: $$cpu_arch"
|
||||
if [ "$$cpu_arch" == "armv6"* ]; then \
|
||||
echo "----- CPU Architecture is ARMv6 or compatible. -----\n----- CPU Architectre is not compatible with dependencies of this project, please use a newer CPU architecture -----\n"; \
|
||||
exit; \
|
||||
fi
|
||||
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
|
||||
|
||||
install_pdab:
|
||||
# Install Python DAB
|
||||
git clone -b DRBv3 https://git.vpn.cusano.net/logan/Python-Discord-Audio-Bot.git ./$(PDAB_DIR)/pdab
|
||||
pip3 install --system -r ./$(PDAB_DIR)/pdab/requirements.txt
|
||||
|
||||
generate_env_file:
|
||||
# Generate .env file
|
||||
echo "# Client Config" > .env
|
||||
echo "CLIENT_NUID=0" >> .env
|
||||
client_name=$$(shell read -p "Enter the name for this node: " input && echo $$input)
|
||||
echo "CLIENT_NAME=$$client_name" >> .env
|
||||
client_location=$$(shell read -p "Enter the location of this node: " input && echo $$input)
|
||||
echo "CLIENT_LOCATION=$$client_location" >> .env
|
||||
client_capabilities=$$(shell read -p "Select CLIENT_CAPABILITIES (comma-separated, default: radio): " input && echo "$${input:-radio}")
|
||||
echo "CLIENT_CAPABILITIES=$$client_capabilities" >> .env
|
||||
# Additional configuration (SERVER_IP, SERVER_PORT, OP25_FULL_PATH, CONFIG_PATH, AUDIO_DEVICE_ID, PDAB_PORT, NODE_ENV) can be added here
|
||||
|
||||
add_systems_to_presets:
|
||||
# Create a JSON object to store nearby systems
|
||||
systems_json="{"
|
||||
while true; do \
|
||||
systems_json+="$$($(shell read -p "Enter system name: " system_name && \
|
||||
read -p "Enter frequencies (comma-separated): " frequencies && \
|
||||
read -p "Enter mode (p25/nbfm): " mode && \
|
||||
if [ "$$mode" == "p25" ]; then \
|
||||
read -p "Enter trunk file: " trunk_file && \
|
||||
read -p "Enter whitelist file: " whitelist_file; \
|
||||
fi && \
|
||||
echo "\"$$system_name\": {\"frequencies\": [\"$$(echo "$$frequencies" | sed 's/,/","/g')\"],\"mode\": \"$$mode\",\"trunkFile\": \"$$trunk_file\",\"whitelistFile\": \"$$whitelist_file\"},"))"
|
||||
read -p "Do you want to add another system? (yes/no): " choice; \
|
||||
if [ "$$choice" != "yes" ]; then \
|
||||
break; \
|
||||
fi; \
|
||||
done
|
||||
systems_json=$$(echo "$$systems_json" | sed 's/,$$//') # Remove trailing comma
|
||||
systems_json+="}"
|
||||
mkdir -p ./config
|
||||
echo "$$systems_json" > "./config/radioPresets.json"
|
||||
|
||||
install_op25:
|
||||
# Clone OP25 from the git repository
|
||||
git clone -b gr310 https://github.com/boatbod/op25.git $(OP25_DIR)
|
||||
# Edit the startup script to use the active.cfg.json config file generated by the app
|
||||
sed -i 's/p25_rtl_example.json/active.cfg.json/g' $(OP25_DIR)/op25-multi_rx.sh
|
||||
# Move the startup script to the apps dir
|
||||
mv $(OP25_DIR)/op25-multi_rx.sh $(OP25_DIR)/op25/gr-op25_repeater/apps/
|
||||
# Install OP25 using the provided installation script
|
||||
$(OP25_DIR)/install.sh
|
||||
|
||||
set_permissions:
|
||||
# Setting permissions on the directories created
|
||||
chown -R 1000:1000 ./*
|
||||
chown 1000:1000 .env
|
||||
|
||||
reboot:
|
||||
# Prompt the user for reboot confirmation
|
||||
read -p "This script has installed all required components for the DRB client. Are you okay with rebooting? If not, you will have to reboot later before running the applications to finish the installation. (Reboot?: y/n): " confirm
|
||||
confirm=$$(echo "$$confirm" | tr '[:upper:]' '[:lower:]') # Convert to lowercase
|
||||
if [ "$$confirm" != "y" ] && [ "$$confirm" != "yes" ]; then \
|
||||
# Prompt user to press any key before rebooting
|
||||
read -rsp $$'System will now reboot, press any key to continue or Ctrl+C to cancel...\n' -n1 key; \
|
||||
echo "Rebooting..."; \
|
||||
reboot; \
|
||||
else \
|
||||
echo "Please restart your device to complete the installation"; \
|
||||
fi
|
||||
@@ -2,6 +2,7 @@ import { generateUniqueID } from './modules/baseUtils.mjs';
|
||||
import { updateId } from './modules/updateConfig.mjs';
|
||||
import { ClientNodeConfig } from './modules/clientObjectDefinitions.mjs';
|
||||
import { initSocketConnection } from './modules/socketClient.mjs';
|
||||
import { checkForUpdates } from './modules/selfUpdater.mjs'
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config()
|
||||
@@ -9,6 +10,9 @@ dotenv.config()
|
||||
var localNodeConfig = new ClientNodeConfig({})
|
||||
|
||||
async function boot() {
|
||||
// Check if there have been any updates
|
||||
await checkForUpdates();
|
||||
|
||||
if (localNodeConfig.node.nuid === undefined || localNodeConfig.node.nuid === '' || localNodeConfig.node.nuid === '0' || localNodeConfig.node.nuid === 0) {
|
||||
// Run the first time boot sequence
|
||||
await firstTimeBoot();
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
npm install
|
||||
# Install client package updates
|
||||
npm install
|
||||
|
||||
# Install OP25 Updates
|
||||
cd ./op25
|
||||
bash rebuild.sh
|
||||
|
||||
# Check for PDAB updates
|
||||
cd ../discordAudioBot/pdab
|
||||
git pull
|
||||
Reference in New Issue
Block a user