105 lines
2.4 KiB
Bash
Executable File
105 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Example WireGuard Setup Script
|
|
# This demonstrates how to use the main setup script with predefined values
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
print_status() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_header() {
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo -e "${BLUE}$1${NC}"
|
|
echo -e "${BLUE}================================${NC}"
|
|
}
|
|
|
|
# Example: Creating a client configuration similar to aza.conf
|
|
create_client_example() {
|
|
print_header "Creating Client Configuration Example"
|
|
|
|
# Create a temporary input file for the main script
|
|
cat > /tmp/wg_input.txt << 'EOF'
|
|
test_client
|
|
10.8.0.5/24
|
|
n
|
|
y
|
|
n
|
|
EOF
|
|
|
|
print_status "Running setup script with client configuration..."
|
|
echo "This will create a client configuration similar to aza.conf"
|
|
echo ""
|
|
|
|
# Run the main script with the example inputs
|
|
./wireguard_setup.sh < /tmp/wg_input.txt
|
|
|
|
# Clean up
|
|
rm -f /tmp/wg_input.txt
|
|
|
|
print_status "Client example configuration created!"
|
|
}
|
|
|
|
# Example: Creating a server configuration similar to zion.conf
|
|
create_server_example() {
|
|
print_header "Creating Server Configuration Example"
|
|
|
|
# Create a temporary input file for the main script
|
|
cat > /tmp/wg_input.txt << 'EOF'
|
|
test_server
|
|
10.8.0.1/24
|
|
y
|
|
51820
|
|
n
|
|
EOF
|
|
|
|
print_status "Running setup script with server configuration..."
|
|
echo "This will create a server configuration similar to zion.conf"
|
|
echo ""
|
|
|
|
# Run the main script with the example inputs
|
|
./wireguard_setup.sh < /tmp/wg_input.txt
|
|
|
|
# Clean up
|
|
rm -f /tmp/wg_input.txt
|
|
|
|
print_status "Server example configuration created!"
|
|
}
|
|
|
|
# Show usage
|
|
show_usage() {
|
|
echo "Usage: $0 [OPTION]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " client Create a client configuration example"
|
|
echo " server Create a server configuration example"
|
|
echo " help Show this help message"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 client # Creates a client config like aza.conf"
|
|
echo " $0 server # Creates a server config like zion.conf"
|
|
}
|
|
|
|
# Main logic
|
|
case "${1:-help}" in
|
|
client)
|
|
create_client_example
|
|
;;
|
|
server)
|
|
create_server_example
|
|
;;
|
|
help|--help|-h)
|
|
show_usage
|
|
;;
|
|
*)
|
|
print_error "Unknown option: $1"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac |