0.2.8
This commit is contained in:
@@ -1,10 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build the client and server
|
||||
echo "Building Reticulum client..."
|
||||
go build -o bin/reticulum-client ./cmd/client
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Usage: $0 [--type TYPE]"
|
||||
echo " --type Type of client to run (default: client, options: client, ftp)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
CLIENT_TYPE="client"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--type)
|
||||
CLIENT_TYPE="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate client type
|
||||
if [[ "$CLIENT_TYPE" != "client" && "$CLIENT_TYPE" != "ftp" ]]; then
|
||||
echo "Error: Invalid client type. Must be 'client' or 'ftp'"
|
||||
show_usage
|
||||
fi
|
||||
|
||||
# Build the appropriate binaries
|
||||
echo "Building Reticulum binaries..."
|
||||
go build -o bin/reticulum ./cmd/reticulum
|
||||
|
||||
case $CLIENT_TYPE in
|
||||
"client")
|
||||
go build -o bin/reticulum-client ./cmd/client
|
||||
CLIENT_BIN="reticulum-client"
|
||||
;;
|
||||
"ftp")
|
||||
go build -o bin/reticulum-client-ftp ./cmd/client-ftp
|
||||
CLIENT_BIN="reticulum-client-ftp"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check if build was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Build failed!"
|
||||
@@ -23,8 +60,8 @@ sleep 2 # Give server time to start
|
||||
|
||||
# Generate identities for both clients
|
||||
echo "Generating identities..."
|
||||
CLIENT1_HASH=$(./bin/reticulum-client -config configs/test-client1.toml -generate-identity 2>&1 | grep "Identity hash:" | cut -d' ' -f3)
|
||||
CLIENT2_HASH=$(./bin/reticulum-client -config configs/test-client2.toml -generate-identity 2>&1 | grep "Identity hash:" | cut -d' ' -f3)
|
||||
CLIENT1_HASH=$(./bin/"$CLIENT_BIN" -config configs/test-client1.toml -generate-identity 2>&1 | grep "Identity hash:" | cut -d' ' -f3)
|
||||
CLIENT2_HASH=$(./bin/"$CLIENT_BIN" -config configs/test-client2.toml -generate-identity 2>&1 | grep "Identity hash:" | cut -d' ' -f3)
|
||||
|
||||
echo "Client 1 Hash: $CLIENT1_HASH"
|
||||
echo "Client 2 Hash: $CLIENT2_HASH"
|
||||
@@ -34,15 +71,35 @@ run_client() {
|
||||
local config=$1
|
||||
local target=$2
|
||||
local logfile=$3
|
||||
echo "Starting client with config: $config targeting: $target"
|
||||
./bin/reticulum-client -config "$config" -target "$target" > "$logfile" 2>&1 &
|
||||
|
||||
case $CLIENT_TYPE in
|
||||
"client")
|
||||
echo "Starting regular client with config: $config targeting: $target"
|
||||
./bin/"$CLIENT_BIN" -config "$config" -target "$target" > "$logfile" 2>&1 &
|
||||
;;
|
||||
"ftp")
|
||||
echo "Starting FTP client with config: $config serving directory: $target"
|
||||
./bin/"$CLIENT_BIN" -config "$config" -serve "$target" > "$logfile" 2>&1 &
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $! > "$logfile.pid"
|
||||
echo "Client started with PID: $(cat $logfile.pid)"
|
||||
}
|
||||
|
||||
# Run both clients targeting each other
|
||||
run_client "configs/test-client1.toml" "$CLIENT2_HASH" "logs/client1.log"
|
||||
run_client "configs/test-client2.toml" "$CLIENT1_HASH" "logs/client2.log"
|
||||
# Run both clients with appropriate parameters
|
||||
case $CLIENT_TYPE in
|
||||
"client")
|
||||
run_client "configs/test-client1.toml" "$CLIENT2_HASH" "logs/client1.log"
|
||||
run_client "configs/test-client2.toml" "$CLIENT1_HASH" "logs/client2.log"
|
||||
;;
|
||||
"ftp")
|
||||
# Create shared directories for FTP clients
|
||||
mkdir -p ./shared/client1 ./shared/client2
|
||||
run_client "configs/test-client1.toml" "./shared/client1" "logs/client1.log" "$CLIENT2_HASH"
|
||||
run_client "configs/test-client2.toml" "./shared/client2" "logs/client2.log" "$CLIENT1_HASH"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo
|
||||
echo "Both clients are running. To stop everything:"
|
||||
@@ -50,4 +107,11 @@ echo "kill \$(cat logs/*.pid)"
|
||||
echo
|
||||
echo "To view logs:"
|
||||
echo "tail -f logs/client1.log"
|
||||
echo "tail -f logs/client2.log"
|
||||
echo "tail -f logs/client2.log"
|
||||
|
||||
if [ "$CLIENT_TYPE" = "ftp" ]; then
|
||||
echo
|
||||
echo "FTP shared directories:"
|
||||
echo "./shared/client1"
|
||||
echo "./shared/client2"
|
||||
fi
|
||||
Reference in New Issue
Block a user