From 3950d57b7f62a47d6a8fd032d413ca826065f5bd Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 12 May 2024 22:53:01 -0400 Subject: [PATCH] Removed config from setup.sh --- setup.sh | 133 +++---------------------------------------------------- 1 file changed, 6 insertions(+), 127 deletions(-) diff --git a/setup.sh b/setup.sh index e7e488a..17f350c 100644 --- a/setup.sh +++ b/setup.sh @@ -22,70 +22,6 @@ if ! id "pi" &>/dev/null; then exit 1 fi -####------------------- Functions -# Function to prompt user for input with a specific message and store the result in a variable -prompt_user() { - if [[ "$TEST_MODE" == "true" ]]; then - echo "TESTING" # Use the pre-set value - else - read -p "$1: " input - echo "$input" - fi -} - -# Function to prompt user for capabilities options and store the result in a variable -prompt_capabilities() { - if [[ "$TEST_MODE" == "true" ]]; then - echo "radio" # Use the pre-set value - else - default_capabilities="radio" # Default value - read -p "Select CLIENT_CAPABILITIES (comma-separated, default: $default_capabilities): " capabilities - capabilities="${capabilities:-$default_capabilities}" # Use default value if input is empty - echo "$capabilities" - fi -} - -# Function to prompt user for nearby systems details -prompt_nearby_system() { - if [[ "$TEST_MODE" == "true" ]]; then - echo "\"TESTING-Node\": { - \"frequencies\": [\"$(echo "155750000,154750000,156555550" | sed 's/,/","/g')\"], - \"mode\": \"p25\", - \"trunkFile\": \"testing_trunk.tsv\", - \"whitelistFile\": \"testing_whitelist.tsv\" - }," # Use the pre-set value - else - local system_name="" - local frequencies="" - local mode="" - local trunk_file="" - local whitelist_file="" - - 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\" - }," - fi -} - -# Check if test mode is enabled -if [[ "$1" == "--test" ]]; then - TEST_MODE="true" -else - TEST_MODE="false" -fi - # Install Node Repo # Get the CPU architecture cpu_arch=$(uname -m) @@ -161,60 +97,7 @@ echo "Installing PDAB and Dependencies" git clone -b DRBv3 https://git.vpn.cusano.net/logan/Python-Discord-Audio-Bot.git ./discordAudioBot/pdab pip3 install -r ./discordAudioBot/pdab/requirements.txt -# Generate .env file -echo "Creating the config .env file..." -echo "# Client Config" > .env -echo "CLIENT_NUID=0" >> .env -client_name=$(prompt_user "Enter the name for this node") -echo "CLIENT_NAME=$client_name" >> .env -client_location=$(prompt_user "Enter the location of this node") -echo "CLIENT_LOCATION=$client_location" >> .env -client_capabilities=$(prompt_capabilities) -echo "CLIENT_CAPABILITIES=$client_capabilities" >> .env - -# Server configuration (preset values) -echo "" >> .env -echo "# Configuration for the connection to the server" >> .env -echo "SERVER_IP=vpn.cusano.net" >> .env -echo "SERVER_PORT=3000" >> .env - -# OP25 configuration (preset values) -echo "" >> .env -echo "# Configuration for OP25" >> .env -op25_full_path="$(pwd)/op25/op25/gr-op25_repeater/apps" # Update this with the actual path -echo "OP25_FULL_PATH=$op25_full_path" >> .env - -# Core configuration (preset value) -echo "" >> .env -echo "# Core config, DO NOT TOUCH UNLESS YOU KNOW WHAT YOU ARE DOING" >> .env -echo "CONFIG_PATH=./config/radioPresets.json" >> .env -runuser -l pi -c 'python3 ./discordAudioBot/pdab/getDevices.py' -audio_device_id=$(prompt_user "Enter the ID of the 'input' audio device you would like to use (most often 'default')") -echo "AUDIO_DEVICE_ID=$audio_device_id" >> .env -echo "PDAB_PORT=3110" >> .env -echo "NODE_ENV=production" >> .env - -echo ".env file generated successfully." - -# Create a JSON object to store nearby systems -systems_json="{" -while true; do - systems_json+="$(prompt_nearby_system)" - read -p "Do you want to add another system? (yes/no): " choice - if [[ "$choice" != "yes" ]]; then - break - fi -done -systems_json="${systems_json%,}" # Remove trailing comma -systems_json+="}" - -# Append the created systems to the presets file -mkdir -p ./config -echo "$systems_json" >> "./config/radioPresets.json" - -echo "Systems added to radioPresets.json." - -# Create a systemd service file +# Create a systemd service file for the DRB Client echo "Adding DRB Node service..." service_content="[Unit] Description=Discord-Radio-Bot_v3 @@ -239,7 +122,7 @@ echo "$service_content" > /etc/systemd/system/discord-radio-bot.service systemctl daemon-reload systemctl enable discord-radio-bot.service -echo "\n\n\t\tDiscord Client Node install completed!\n\n" +echo "\n\n\t\tDRB Client install completed!\n\n" ####------------------- OP25 Installation # Clone OP25 from the git repository @@ -304,11 +187,7 @@ confirm="${confirm,,}" #echo "To configure the app, please go to http://$nodeIP:$nodePort" # TODO - uncomment when webapp is built echo "Thank you for joining the network!" -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 \ No newline at end of file +# 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 \ No newline at end of file