9 Commits

Author SHA1 Message Date
Logan Cusano
ca2815ab8f Improve the update script to use the owner of the git repo 2023-08-06 16:49:31 -04:00
Logan Cusano
556697725a Much improved install script for clients #6 2023-08-06 16:40:10 -04:00
Logan Cusano
b448f04aec Commenting out variables not set by the initial config 2023-08-06 16:27:04 -04:00
Logan Cusano
fae8417b2f Add log file location to the example ENV 2023-08-06 00:46:00 -04:00
Logan Cusano
e06cc4762d Using absolute file path for pdab binaries 2023-08-06 00:45:24 -04:00
Logan Cusano
6deba2bad2 Fix bug that used wrong env var for client port 2023-08-05 03:11:59 -04:00
Logan Cusano
e0d1a4a2fe Update client setup
- get user input for client config
- update pulseaudio setup to run for all users
- add op25 installer
2023-08-05 03:11:32 -04:00
1078faa766 Merge pull request '#37 Implement v1 Web Apps' (#41) from #37-implement-webapps into master
Reviewed-on: #41
2023-08-04 23:46:46 -04:00
Logan Cusano
75580c0547 Fix bug in httprequests, hostname was overwritten 2023-08-04 23:44:28 -04:00
6 changed files with 175 additions and 36 deletions

View File

@@ -17,4 +17,7 @@ SERVER_HOSTNAME=""
SERVER_PORT=3000
# Configuration of the local OP25 application
OP25_BIN_PATH=""
#OP25_BIN_PATH=""
# Logfile location config
#LOG_LOCATION=""

View File

@@ -17,7 +17,7 @@ var { attachRadioSessionToRequest } = require('./controllers/radioController');
const log = new DebugBuilder("client", "app");
var app = express();
var port = process.env.HTTP_PORT || '3010';
var port = process.env.CLIENT_PORT || '3010';
// view engine setup
app.set('views', path.join(__dirname, 'views'));

View File

@@ -8,20 +8,21 @@ async def load_opus():
# Check the system type and load the correct library
# Linux ARM AARCH64 running 32bit OS
processor = platform.machine()
script_dir = os.path.dirname(os.path.abspath(__file__))
print("Processor: ", processor)
if os.name == 'nt':
if processor == "AMD64":
if processor == "AMD64":
opus.load_opus(os.path.join(script_dir, './opus/libopus_amd64.dll'))
print(f"Loaded OPUS library for AMD64")
opus.load_opus('./opus/libopus_amd64.dll')
return "AMD64"
else:
if processor == "aarch64":
if processor == "aarch64":
opus.load_opus(os.path.join(script_dir, './opus/libopus_aarcch64.so'))
print(f"Loaded OPUS library for aarch64")
opus.load_opus('./opus/libopus_aarcch64.so')
return "aarch64"
elif processor == "armv7l":
elif processor == "armv7l":
opus.load_opus(os.path.join(script_dir, './opus/libopus_armv7l.so'))
print(f"Loaded OPUS library for armv7l")
opus.load_opus('./opus/libopus_armv7l.so')
return "armv7l"

View File

@@ -5,21 +5,81 @@ if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Prompt the user for reboot confirmation
read -p "This script will install all required components for the DRB client. Are you okay with rebooting afterward? If not, you will have to reboot later before running the applications to finish the installation. (Reboot?: y/n): " confirm
# Convert user input to lowercase for case-insensitive comparison
confirm="${confirm,,}"
if [[ "$confirm" != "y" && "$confirm" != "yes" ]]; then
echo "Script will not reboot."
should_reboot=false
else
echo "Script will reboot after completion."
should_reboot=true
fi
echo "----- Starting Radio Node Client Install Script -----"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ls -ld $SCRIPT_DIR | awk '{print $3}' >> ./config/installerName
# Copy the example env file
cp .env.example .env
# Setup user for service
useradd -M RadioNode
usermod -s -L RadioNode
# Copy the radio config example file
cp config/radioPresets.json.EXAMPLE config/radioPresets.json
# Change the ownership of the directory to the service user
chown RadioNode -R $SCRIPT_DIR
echo "----- Collecting Setup Information -----"
# Check for updates
apt-get update
# Ask the user for input and store in variables
echo " \\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
echo " \\Server Config"
read -p " Enter Server IP (leave blank if using hostname): " serverIP
if [ -z "$serverIP" ]; then
read -p " Enter Server Hostname: " serverHostname
fi
read -p " Enter Server Port: " serverPort
# 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
if [ -z "$serverIP" ]; then
sed -i "s/^SERVER_HOSTNAME=\".*\"$/SERVER_HOSTNAME=\"$serverHostname\"/" .env
else
sed -i "s/^SERVER_IP=\".*\"$/SERVER_IP=\"$serverIP\"/" .env
fi
sed -i "s/^SERVER_PORT=\".*\"$/SERVER_PORT=\"$serverPort\"/" .env
echo "----- Config file has been updated -----"
# Display the updated values
echo "----- Start of Config File -----"
cat .env
echo "----- End of Config File -----"
echo "----- Getting Dependencies -----"
# Install Node Repo
# Get the CPU architecture
cpu_arch=$(uname -m)
# Print the CPU architecture for verification
echo "Detected CPU Architecture: $cpu_arch"
# Check if the architecture is ARMv6
if [[ "$cpu_arch" == "armv6"* ]]; then
echo "----- CPU Architecture is ARMv6 or compatible. -----"
echo "----- CPU Architectre is not compatible with dependencies of this project, please use a newer CPU architecture -----"
exit
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
# Update the system
@@ -27,16 +87,41 @@ 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
# Ensure pulse audio is running
pulseaudio
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
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 pi
# Enable the PulseAudio service
systemctl enable PulseAudio.service
echo "----- Setting up Radio Node Service -----"
# Setup bot service
echo "[Unit]
@@ -44,32 +129,80 @@ Description=Radio Node Service
After=network.target
[Service]
WorkingDirectory="$SCRIPT_DIR"
WorkingDirectory=$SCRIPT_DIR/
ExecStart=/usr/bin/node .
Restart=always
RestartDelay=10
User=RadioNode
Environment=DEBUG='client:*'
Environment=\"DEBUG='client:*'\"
[Install]
WantedBy=multi-user.target" >> /etc/systemd/system/RadioNode.service
# Enable the Radio Node service
systemctl enable 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"
WorkingDirectory=$SCRIPT_DIR/
ExecStart=/usr/bin/bash update.sh
Restart=on-failure
User=RadioNode
[Install]
WantedBy=multi-user.target" >> /etc/systemd/system/RadioNodeUpdater.service
# Enable the service
systemctl enable RadioNode.service
# Install OP25
echo "----- Installing OP25 from Source -----"
# Clone the OP25 Git
cd /opt/
git clone https://github.com/boatbod/op25.git
cd op25
# Start the service
systemctl start RadioNode.service
# 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
echo "----- Setup Complete! -----"
# Reboot if the user confirmed earlier
if [ "$should_reboot" = true ]; then
echo "To configure the app, please go to http://$nodeIP:$nodePort"
echo "Thank you for joining the network!"
# 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 "To configure the app, please go to http://$nodeIP:$nodePort"
echo "Thank you for joining the network!"
echo "Please restart your device to complete the installation"
fi

View File

@@ -17,10 +17,12 @@ echo "<!-- UPDATING ---!>"
# Stop any running service
systemctl stop RadioNode
# Update the git Repo
installUser=$(cat ./config/installerName)
sudo su -l $installUser -c 'git fetch -a -p'
sudo su -l $installUser -c 'git pull'
# Get the owner of the current working directory
cwd_owner=$(stat -c '%U' .)
# Update the git Repo as the owner of the current working directory
sudo su -l $cwd_owner -c 'git fetch'
sudo su -l $cwd_owner -c 'git pull'
# Install any new libraries
npm i

View File

@@ -12,8 +12,8 @@ exports.requestOptions = class requestOptions {
if (["POST", "PUT"].includes(method)){
log.VERBOSE("Hostname Vars: ", hostname, process.env.SERVER_HOSTNAME, process.env.SERVER_IP);
if (hostname) this.hostname = hostname;
if (process.env.SERVER_HOSTNAME) this.hostname = process.env.SERVER_HOSTNAME;
if (process.env.SERVER_IP) this.hostname = process.env.SERVER_IP;
if (!this.hostname && process.env.SERVER_HOSTNAME) this.hostname = process.env.SERVER_HOSTNAME;
if (!this.hostname && process.env.SERVER_IP) this.hostname = process.env.SERVER_IP;
if (!this.hostname) throw new Error("No server hostname / IP was given when creating a request");
this.path = path;
this.port = port ?? process.env.SERVER_PORT;