5 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
4 changed files with 91 additions and 40 deletions

View File

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

View File

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

View File

@@ -6,6 +6,20 @@ if [ "$EUID" -ne 0 ]
exit exit
fi 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 -----" echo "----- Starting Radio Node Client Install Script -----"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
@@ -13,35 +27,59 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Copy the example env file # Copy the example env file
cp .env.example .env cp .env.example .env
# Copy the radio config example file
cp config/radioPresets.json.EXAMPLE config/radioPresets.json
echo "----- Collecting Setup Information -----" echo "----- Collecting Setup Information -----"
# Ask the user for input and store in variables # Ask the user for input and store in variables
echo "\t \\Client Config" echo " \\Client Config"
read -p " Enter Node Name: " nodeName read -p " Enter Node Name: " nodeName
read -p " Enter Node IP: " nodeIP read -p " Enter Node IP: " nodeIP
read -p " Enter Node Port: " nodePort read -p " Enter Node Port: " nodePort
read -p " Enter Node Location: " nodeLocation read -p " Enter Node Location: " nodeLocation
read -p " Enter Audio Device ID: " audioDeviceID 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 # Update the values in the env file using sed
sed -i "s/^AUDIO_DEVICE_ID=\".*\"$/AUDIO_DEVICE_ID=\"$audioDeviceID\"/" .env sed -i "s/^AUDIO_DEVICE_ID=\".*\"$/AUDIO_DEVICE_ID=\"$audioDeviceID\"/" .env
sed -i "s/^CLIENT_NAME=\".*\"$/CLIENT_NAME=\"$nodeName\"/" env sed -i "s/^CLIENT_NAME=\".*\"$/CLIENT_NAME=\"$nodeName\"/" .env
sed -i "s/^CLIENT_IP=\".*\"$/CLIENT_IP=\"$nodeIP\"/" env sed -i "s/^CLIENT_IP=\".*\"$/CLIENT_IP=\"$nodeIP\"/" .env
sed -i "s/^CLIENT_PORT=.*$/CLIENT_PORT=$nodePort/" env sed -i "s/^CLIENT_PORT=.*$/CLIENT_PORT=$nodePort/" .env
sed -i "s/^CLIENT_LOCATION=\".*\"$/CLIENT_LOCATION=\"$nodeLocation\"/" 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 # Display the updated values
echo "----- Config file has been updated -----"
echo "----- Start of Config File -----" echo "----- Start of Config File -----"
cat env cat .env
echo "----- End of Config File -----" echo "----- End of Config File -----"
echo "----- Getting Dependencies -----" echo "----- Getting Dependencies -----"
# Check for updates
apt-get update
# Install Node Repo # 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 - curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
# Update the system # Update the system
@@ -78,14 +116,11 @@ WantedBy=multi-user.target" >> /etc/systemd/system/PulseAudio.service
# Add the root user to the pulse-access group # Add the root user to the pulse-access group
usermod -aG pulse-access root usermod -aG pulse-access root
usermod -aG pulse-access usermod -aG pulse-access pi
# Enable the PulseAudio service # Enable the PulseAudio service
systemctl enable PulseAudio.service systemctl enable PulseAudio.service
# Start the PulseAudio service
systemctl start PulseAudio.service
echo "----- Setting up Radio Node Service -----" echo "----- Setting up Radio Node Service -----"
# Setup bot service # Setup bot service
@@ -94,7 +129,7 @@ Description=Radio Node Service
After=network.target After=network.target
[Service] [Service]
WorkingDirectory=\"$SCRIPT_DIR\" WorkingDirectory=$SCRIPT_DIR/
ExecStart=/usr/bin/node . ExecStart=/usr/bin/node .
Restart=always Restart=always
RestartDelay=10 RestartDelay=10
@@ -103,6 +138,9 @@ Environment=\"DEBUG='client:*'\"
[Install] [Install]
WantedBy=multi-user.target" >> /etc/systemd/system/RadioNode.service 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 -----" echo "----- Setting up Radio Node Update Service -----"
# Setup bot update service # Setup bot update service
@@ -111,7 +149,7 @@ Description=Radio Node Updater Service
After=network.target After=network.target
[Service] [Service]
WorkingDirectory=\"$SCRIPT_DIR\" WorkingDirectory=$SCRIPT_DIR/
ExecStart=/usr/bin/bash update.sh ExecStart=/usr/bin/bash update.sh
Restart=on-failure Restart=on-failure
@@ -137,7 +175,7 @@ Description=OP25 Service
After=network.target After=network.target
[Service] [Service]
WorkingDirectory=\"/opt/op25/op25/gr-op25_repeater/apps\" WorkingDirectory=/opt/op25/op25/gr-op25_repeater/apps
ExecStart=./multi_rx.py -c radioNodeOP25Config.json ExecStart=./multi_rx.py -c radioNodeOP25Config.json
Restart=always Restart=always
@@ -153,11 +191,18 @@ echo "----- OP25 Enabled; Please ensure to update the configuration and start th
# Move back to the directory that the user started in (might not be needed?) # Move back to the directory that the user started in (might not be needed?)
cd $SCRIPT_DIR 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! -----" 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 # Stop any running service
systemctl stop RadioNode systemctl stop RadioNode
# Update the git Repo # Get the owner of the current working directory
installUser=$(cat ./config/installerName) cwd_owner=$(stat -c '%U' .)
sudo su -l $installUser -c 'git fetch -a -p'
sudo su -l $installUser -c 'git pull' # 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 # Install any new libraries
npm i npm i