Much improved install script for clients #6
This commit is contained in:
103
Client/setup.sh
103
Client/setup.sh
@@ -6,6 +6,20 @@ if [ "$EUID" -ne 0 ]
|
||||
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 )
|
||||
@@ -13,35 +27,59 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
# Copy the example env file
|
||||
cp .env.example .env
|
||||
|
||||
# Copy the radio config example file
|
||||
cp config/radioPresets.json.EXAMPLE config/radioPresets.json
|
||||
|
||||
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
|
||||
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
|
||||
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 "----- Config file has been updated -----"
|
||||
echo "----- Start of Config File -----"
|
||||
cat env
|
||||
cat .env
|
||||
echo "----- End of Config File -----"
|
||||
|
||||
echo "----- Getting Dependencies -----"
|
||||
|
||||
# Check for updates
|
||||
apt-get update
|
||||
|
||||
# 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
|
||||
@@ -78,14 +116,11 @@ 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
|
||||
usermod -aG pulse-access pi
|
||||
|
||||
# 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
|
||||
@@ -94,7 +129,7 @@ Description=Radio Node Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=\"$SCRIPT_DIR\"
|
||||
WorkingDirectory=$SCRIPT_DIR/
|
||||
ExecStart=/usr/bin/node .
|
||||
Restart=always
|
||||
RestartDelay=10
|
||||
@@ -103,6 +138,9 @@ 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
|
||||
@@ -111,7 +149,7 @@ Description=Radio Node Updater Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=\"$SCRIPT_DIR\"
|
||||
WorkingDirectory=$SCRIPT_DIR/
|
||||
ExecStart=/usr/bin/bash update.sh
|
||||
Restart=on-failure
|
||||
|
||||
@@ -137,7 +175,7 @@ Description=OP25 Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=\"/opt/op25/op25/gr-op25_repeater/apps\"
|
||||
WorkingDirectory=/opt/op25/op25/gr-op25_repeater/apps
|
||||
ExecStart=./multi_rx.py -c radioNodeOP25Config.json
|
||||
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?)
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
# Enable the Radio Node service
|
||||
systemctl enable RadioNode.service
|
||||
echo "----- Setup Complete! -----"
|
||||
|
||||
# Start the Radio Nodeservice
|
||||
echo "----- Starting the Radio Node Service -----"
|
||||
systemctl start RadioNode.service
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user