Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # --- Field-Grade Terminal Colors (Expanded) ---
- C_OFF='\e[0m'
- # Bold
- B_RED='\e[1;31m'
- B_GREEN='\e[1;32m'
- B_YELLOW='\e[1;33m'
- B_BLUE='\e[1;34m'
- B_MAGENTA='\e[1;35m'
- B_CYAN='\e[1;36m'
- B_WHITE='\e[1;37m'
- # Rainbow Sequence
- RAINBOW_COLORS=(
- '\e[1;31m' # Red
- '\e[1;33m' # Yellow (as Orange)
- '\e[1;32m' # Green
- '\e[1;36m' # Cyan
- '\e[1;34m' # Blue
- '\e[1;35m' # Magenta (as Violet)
- )
- # --- NEW: Rainbow Rendering Function ---
- # This function paints each character of a string with a different color.
- rainbow_text() {
- local text="$1"
- local num_colors=${#RAINBOW_COLORS[@]}
- # Use 'tput cols' to get terminal width, default to 51 if not available
- local width=$(tput cols 2>/dev/null || echo 51)
- local padding=$(( (width - ${#text}) / 2 ))
- # Print left padding
- printf "%*s" $padding ""
- # Print rainbow text
- for (( i=0; i<${#text}; i++ )); do
- local char="${text:$i:1}"
- # Prevent coloring spaces to maintain alignment
- if [[ "$char" == " " ]]; then
- printf " "
- else
- # Cycle through the RAINBOW_COLORS array
- local color_index=$((i % num_colors))
- printf "${RAINBOW_COLORS[color_index]}%s" "$char"
- fi
- done
- # Reset color and print a newline
- printf "${C_OFF}\n"
- }
- # --- Mission-Critical Functions (Unchanged Logic) ---
- command_exists() { command -v "$1" &> /dev/null; }
- # --- Primary Operational Functions (Unchanged Logic) ---
- listen_to_hd() {
- if ! command_exists nrsc5; then
- echo -e "${B_RED}[ERROR] 'nrsc5' is not installed.${C_OFF}"
- echo -e "${B_YELLOW}Go to 'Setup & Maintenance' to install it.${C_OFF}"
- read -p "Press [Enter] to continue..."
- return
- fi
- clear
- rainbow_text "--- Begin Listening Operation ---"
- echo -e "${B_YELLOW}Ensure your RTL-SDR is connected.${C_OFF}"
- read -p "Enter target frequency (e.g., 97.1M): " freq
- if [[ -z "$freq" ]]; then
- echo -e "${B_RED}[ABORT] No frequency entered.${C_OFF}"
- read -p "Press [Enter] to continue..."
- return
- fi
- while true; do
- clear
- rainbow_text "Select Program for Frequency: ${freq}"
- echo
- echo -e " ${B_GREEN}[1] HD1 (Primary Program)${C_OFF}"
- echo -e " ${B_CYAN}[2] HD2 (Sub-channel 2)${C_OFF}"
- echo -e " ${B_BLUE}[3] HD3 (Sub-channel 3)${C_OFF}"
- echo -e " ${B_MAGENTA}[4] HD4 (Sub-channel 4)${C_OFF}"
- echo -e " ${B_YELLOW}[5] HD5 (Sub-channel 5)${C_OFF}"
- echo
- echo -e " ${B_RED}[0] Change Frequency / Return${C_OFF}"
- echo
- rainbow_text "-----------------------------------"
- read -p "Select a program to monitor: " prog_choice
- case $prog_choice in
- [1-5])
- let prog_index=$prog_choice-1
- echo -e "${B_GREEN}Tuning to ${freq} on HD program ${prog_choice}... Press [Ctrl+C] to stop.${C_OFF}"
- nrsc5 "$freq" "$prog_index"
- read -p "Listening stopped. Press [Enter] to return..."
- ;;
- 0) return ;;
- *) echo -e "${B_RED}Invalid selection.${C_OFF}" && sleep 1 ;;
- esac
- done
- }
- # --- Setup & Maintenance Functions (Unchanged Logic) ---
- install_dependencies() {
- echo -e "${B_YELLOW}[*] Requesting root access...${C_OFF}"
- sudo apt-get update && sudo apt-get install -y git cmake build-essential librtlsdr-dev libao-dev pkg-config autoconf libtool libfftw3-dev rtl-sdr
- if ! grep -q "blacklist dvb_usb_rtl28xxu" /etc/modprobe.d/blacklist-rtl.conf 2>/dev/null; then
- echo "blacklist dvb_usb_rtl28xxu" | sudo tee /etc/modprobe.d/blacklist-rtl.conf > /dev/null
- echo -e "${B_GREEN}[+] Blacklist rule created. A reboot is recommended.${C_OFF}"
- fi
- echo -e "\n${B_GREEN}[SUCCESS] Dependencies are in place.${C_OFF}"
- read -p "Press [Enter] to return..."
- }
- install_nrsc5() {
- if command_exists nrsc5; then echo -e "${B_GREEN}[*] 'nrsc5' is already installed.${C_OFF}"; read -p "Press [Enter]..."; return; fi
- if [ -d "nrsc5" ]; then rm -rf nrsc5; fi
- echo -e "${B_YELLOW}[*] Cloning repository...${C_OFF}"
- if ! git clone https://github.com/theori-io/nrsc5.git; then echo -e "${B_RED}[FAILURE] Clone failed.${C_OFF}"; read -p "Press [Enter]..."; return; fi
- cd nrsc5
- echo -e "${B_YELLOW}[*] Building from source...${C_OFF}"
- if mkdir -p build && cd build && cmake .. -DINTERNAL_FFTW=OFF && make && sudo make install; then
- echo -e "\n${B_GREEN}[SUCCESS] 'nrsc5' has been installed.${C_OFF}"
- else echo -e "\n${B_RED}[FAILURE] Build process failed.${C_OFF}"; fi
- cd ../..
- read -p "Press [Enter] to return..."
- }
- test_sdr() {
- if ! command_exists rtl_test; then echo -e "${B_RED}[ERROR] 'rtl-sdr' not found. Use Option [1].${C_OFF}"; else
- echo -e "${B_YELLOW}[*] Running SDR diagnostic...${C_OFF}"; rtl_test -t
- echo -e "\n${B_GREEN}If you see device info, your SDR is working.${C_OFF}"; fi
- read -p "Press [Enter] to return..."
- }
- # --- Menu Display Functions (Visually Overhauled) ---
- show_setup_menu() {
- while true; do
- clear
- rainbow_text "--- Setup & Maintenance ---"
- echo
- echo -e " ${B_GREEN}[1] Install/Update Dependencies${C_OFF}"
- echo -e " ${B_CYAN}[2] Compile/Install 'nrsc5' Decoder${C_OFF}"
- echo -e " ${B_YELLOW}[3] Test RTL-SDR Device Connection${C_OFF}"
- echo
- echo -e " ${B_RED}[0] Return to Main Menu${C_OFF}"
- echo
- rainbow_text "---------------------------------"
- read -p "Select an option: " setup_choice
- case $setup_choice in
- 1) install_dependencies ;;
- 2) install_nrsc5 ;;
- 3) test_sdr ;;
- 0) break ;;
- *) echo -e "${B_RED}Invalid selection.${C_OFF}" && sleep 1 ;;
- esac
- done
- }
- # --- Main Operational Loop (Visually Overhauled) ---
- while true; do
- clear
- rainbow_text "H.D.R. - v1.7 // Covert Radio Operations"
- echo
- echo -e " ${B_CYAN}SDR Activated. Awaiting Tasking.${C_OFF}"
- echo
- echo -e " ${B_BLUE} [1] Listen to HD Radio Broadcast${C_OFF}"
- echo -e " ${B_MAGENTA}[2] Setup & Maintenance${C_OFF}"
- echo
- echo -e " ${B_RED} [0] Exit and Clean Traces${C_OFF}"
- echo
- rainbow_text "---------------------------------------------------"
- read -p "Select an option [0-2]: " choice
- case $choice in
- 1) listen_to_hd ;;
- 2) show_setup_menu ;;
- 0) echo -e "${B_RED}Disengaging. Clean your tracks.${C_OFF}"; break ;;
- *) echo -e "${B_RED}Invalid selection.${C_OFF}"; sleep 1 ;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement