#!/bin/bash # This file serves as as an example of how I launch the debug server and client in a tmux session for what I call "Bodeting" (Bodet Alarm and Gong) testing # Parse command line arguments SUDO_PASSWORD="mlol-no" while getopts "p:" opt; do case $opt in p) SUDO_PASSWORD="$OPTARG" ;; *) echo "Usage: $0 [-p sudo_password]" >&2; exit 1 ;; esac done # Create directory for client configs if it doesn't exist mkdir -p configs # Create server config with multicast groups cat > configs/server_config.toml << EOF secret = "bodeting-secret-key-so-much-secure" listen_ip = "0.0.0.0" listen_port = 8989 simple_auth = true [multicast_groups] # Bodet Alarm group for 239.192.55.2 [multicast_groups.bodetalarm] address = "239.192.55.2" port = 1681 # Bodet Gong group for 239.192.55.1 [multicast_groups.bodetgong] address = "239.192.55.1" port = 1681 # Test client authorizations [[authorized_clients]] name = "localhost" ip_address = "127.0.0.1" group_ids = [] # Empty means all groups EOF # Create debug agent config cat > configs/debug_agent_config.toml << EOF secret = "bodeting-secret-key-so-much-secure" server = "127.0.0.1" port = 8989 multicast_group_ids = [] # Set to true for debug mode test_mode = true EOF # Check if tmux is already running if [ -z "$TMUX" ]; then # Start a new tmux session tmux new-session -d -s debug_server # Split the window horizontally (side by side) tmux split-window -h -t debug_server:0.0 # Configure the left pane for the server if [ -n "$SUDO_PASSWORD" ]; then tmux send-keys -t debug_server:0.0 "cd $(pwd) && clear && echo 'Starting server...' && echo '$SUDO_PASSWORD' | sudo -S RUST_LOG=debug ./target/release/castrepeat-server --config configs/server_config.toml" C-m else tmux send-keys -t debug_server:0.0 "cd $(pwd) && clear && echo 'Starting server...' && sudo RUST_LOG=debug ./target/release/castrepeat-server --config configs/server_config.toml" C-m fi # Give the server a moment to start up sleep 2 # Configure the right pane for the debug agent tmux send-keys -t debug_server:0.1 "cd $(pwd) && clear && echo 'Starting debug agent...' && RUST_LOG=debug ./target/release/castrepeat-client --config configs/debug_agent_config.toml" C-m # If you need to test multicast traffic generation, you can add: # tmux split-window -v -t debug_server:0.1 # tmux send-keys -t debug_server:0.2 "cd $(pwd) && clear && echo 'Starting multicast generator...' && RUST_LOG=debug ./target/release/castrepeat-mcast-test" C-m # Attach to the session tmux attach-session -t debug_server else echo "Already in a tmux session. Please exit current tmux session before running this script." exit 1 fi