Skip to content

Instantly share code, notes, and snippets.

@shikendon
Last active March 1, 2024 09:52
Show Gist options
  • Save shikendon/6d0ef4e9a2f185f39e9c191a0dd32ddd to your computer and use it in GitHub Desktop.
Save shikendon/6d0ef4e9a2f185f39e9c191a0dd32ddd to your computer and use it in GitHub Desktop.
Debian network optimization scripts.
#!/bin/bash
# Author: Shi-Ken Don <shiken.don@gmail.com>
# Source: https://git.io/deploy-google-bbr.sh
# License: MIT
set -e
sudo -V > /dev/null || apt -y install sudo
if [[ ! -e /etc/sysctl.d/11-google-bbr.conf ]]; then
cat <<END | sudo tee /etc/sysctl.d/11-google-bbr.conf
# `/sbin/sysctl net.core.default_qdisc`
net.core.default_qdisc = fq
# `/sbin/sysctl net.ipv4.tcp_congestion_control`
net.ipv4.tcp_congestion_control = bbr
END
fi
sudo sysctl -p /etc/sysctl.d/11-google-bbr.conf
#!/bin/bash
# Author: Shi-Ken Don <shiken.don@gmail.com>
# Source: https://git.io/deploy-haproxy.sh
# License: MIT
EXPOSED_PORT=${EXPOSED_PORT:-25565}
BACKEND_HOST=${BACKEND_HOST:-1.2.3.4:25565}
set -e
sudo -V > /dev/null || apt -y install sudo
sudo apt -y install haproxy
if [[ ! -e /etc/haproxy/haproxy.cfg.bak ]]; then
sudo /bin/cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
fi
sudo /bin/cp /etc/haproxy/haproxy.cfg.bak /etc/haproxy/haproxy.cfg
cat <<END | sudo tee -a /etc/haproxy/haproxy.cfg
listen minecraft
bind :${EXPOSED_PORT}
mode tcp
balance leastconn
option tcp-check
server minecraft1 ${BACKEND_HOST} send-proxy
END
sudo systemctl enable haproxy
sudo systemctl restart haproxy
#!/bin/bash
# Author: Shi-Ken Don <shiken.don@gmail.com>
# Source: https://git.io/enable-rc-local.sh
# License: MIT
set -e
sudo -V > /dev/null || apt -y install sudo
if [[ ! -e /etc/rc.local ]]; then
cat <<END | sudo tee /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Load kernel variables from /etc/sysctl.d
/etc/init.d/procps restart
exit 0
END
fi
sudo chmod +x /etc/rc.local
#!/bin/bash
# Author: Shi-Ken Don <shiken.don@gmail.com>
# Source: https://git.io/install-stackdriver-agent.sh
# License: MIT
set -e
sudo -V > /dev/null || apt -y install sudo
curl -fsSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh
sudo apt -y update
sudo apt -y install stackdriver-agent
sudo systemctl enable stackdriver-agent
sudo systemctl start stackdriver-agent
#!/bin/bash
# Author: Shi-Ken Don <shiken.don@gmail.com>
# Source: https://git.io/update-apt.sh
# License: MIT
set -e
sudo -V > /dev/null || apt -y install sudo
while lsof /var/lib/dpkg/lock-frontend; do sleep 1; done
sudo apt -y remove unattended-upgrades
sudo apt -y update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment