Skip to content

Commit

Permalink
Create main.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
FReak4L authored Sep 27, 2024
1 parent 2976400 commit 3c31fa4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

source /src/config.sh
source /src/network_tests.sh
source /src/optimization.sh
source /src/apply_settings.sh

check_dependencies() {
command -v iperf3 >/dev/null 2>&1 || { echo >&2 "iperf3 is required but not installed. Aborting."; exit 1; }
command -v tc >/dev/null 2>&1 || { echo >&2 "tc is required but not installed. Aborting."; exit 1; }
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but not installed. Aborting."; exit 1; }
}

main() {
check_dependencies

echo -e "${YELLOW}Starting network optimization...${NC}"
echo -e "${YELLOW}Current network settings:${NC}"
sysctl -a | grep -E 'tcp_congestion_control|tcp_rmem|tcp_wmem|tcp_fastopen|tcp_tw_reuse|mptcp|tcp_max_syn_backlog|tcp_synack_retries|tcp_syn_retries|tcp_max_tw_buckets|tcp_fin_timeout|netdev_max_backlog|tcp_keepalive|tcp_user_timeout|tcp_window_scaling|tcp_mtu_probing|tcp_slow_start_after_idle|tcp_notsent_lowat|tcp_no_metrics_save|tcp_moderate_rcvbuf|tcp_timestamps|tcp_sack|tcp_fack|tcp_ecn|tcp_dsack|tcp_low_latency|ip_no_pmtu_disc|tcp_adv_win_scale|tcp_rfc1337|tcp_abort_on_overflow|tcp_thin_linear_timeouts|tcp_limit_output_bytes'
tc qdisc show dev $INTERFACE
ip route show default

best_combo=$(optimize_network)

echo -e "${YELLOW}Applying best settings...${NC}"
apply_best_settings "$best_combo"

echo -e "${GREEN}Optimization complete.${NC}"
echo -e "${YELLOW}Final settings:${NC}"
sysctl -a | grep -E 'tcp_congestion_control|tcp_rmem|tcp_wmem|tcp_fastopen|tcp_tw_reuse|mptcp|tcp_max_syn_backlog|tcp_synack_retries|tcp_syn_retries|tcp_max_tw_buckets|tcp_fin_timeout|netdev_max_backlog|tcp_keepalive|tcp_user_timeout|tcp_window_scaling|tcp_mtu_probing|tcp_slow_start_after_idle|tcp_notsent_lowat|tcp_no_metrics_save|tcp_moderate_rcvbuf|tcp_timestamps|tcp_sack|tcp_fack|tcp_ecn|tcp_dsack|tcp_low_latency|ip_no_pmtu_disc|tcp_adv_win_scale|tcp_rfc1337|tcp_abort_on_overflow|tcp_thin_linear_timeouts|tcp_limit_output_bytes'
tc qdisc show dev $INTERFACE
ip route show default
}

trap 'echo "An error occurred. Exiting..."; exit 1' ERR

main

0 comments on commit 3c31fa4

Please sign in to comment.